How can COM Components benefit my ASPs?
There are many advantages to using COM Components instead of scripting the code into an
ASP page itself:
- Code Reuse: Once you have created your COM Component, you can use it again
in a different ASP page or on a different IIS server altogether.
- Code Distribution: You can write COM Components and distribute them just as
you would any other software package - no one needs to know how the COM Component works
- all that's needed is an understanding of the component's methods and properties.
How the component puts everything together is irrelevant to the user.
- Language Support: A COM Component can be written using any programming
language thats COM compliant (capable of creating an ActiveX EXE or DLL).
Also, the scripting language you use in ASP to interact with a COM doesn't matter -
you can use Javascript or VBScript. The COM Component is unaware of the language being
used to set it's properties or call it's methods.
- Maintenance: If you write a COM Component and later need to change the code
in it, there's no need to alter the code in your ASP pages. You simply change the
component's code and recompile it - simple!
- Faster Performance: Because a COM Component (except for an XML component)
is compiled into a binary EXE or DLL, it's faster. This is because ASP is an
interpreted language. The IIS server must interpret the code and finally compile it
before it's put to use - not so with a COM Component.
- Security: Because a COM Component is generally compiled into binary data,
it's pretty difficult for someone interested in seeing (or stealing) how the code
works to do so. So, if you ever wanted to create an awesome COM and are worried that
someone may get a hold of it for the purpose of hacking or simply taking the credit
for your hard work - you don't have to worry about it!
Enforcing N-Tier / Windows© DNA Architecture
You may not even know it but by using COM components, you are using the business/middle
tier of Microsoft©'s proposed N-Tier/Windows© DNA architecture! N-Tier is an architecture or
template that Microsoft© encourges you to use when designing and building applications.
There are essentially three logical tiers: presentation, business, and data:
- Presentation: this is the tier that makes it possible for a user to view and
interact with the appliation. A web browser is a good example of this - it can be used
to display and retrieve information to and from a user.
- Business: this is where the business side of the application come in - things
such as validating account numbers, authenticating user accounts, and calculating state
sales taxes comes in. The presentation tier should mostly be composed of COM components
YOU write!
- Data: this is the tier that is responsible for saving all of the data is
used in both the business and presentation tiers. A good example of this would be
a database, such as SQL Server, a text file, etc.
So, we can summarize the N-tier architecture, for our 'ASP' purposes as...
| Presentation | Browser/Visual Basic Application
|
| Business | Components |
| Data | Stored on Disk
|
Windows© DNA is just N-Tier + Microsoft© Windows© 2000 Products:
| Presentation | Internet Explorer/IIS/Visual Basic
|
| Business | MTS/MSMQ/DCOM/COM/COM+ |
| Data | SQL Server
|
|