I was asked a very interesting question today at our Triad Flex User Group
meeting. What is the difference between components and
modules.
The simple answer is that components are components and
modules are components. But the answer I gave to this question was
this:
Components are components and modules are components
that can be loaded and unloaded from within an application at will.
What does this mean. Well, components are typically a collection of
individual classes that get compiled into an application at
compile-time. Components are almost always compiled into an
application. In my view, modules are components that exist in their
own "wrapper" that the application can load and/or
unload. The only real difference between an application and a module
(at least on the surface) is that the module has a module tag and the
application has an application tag. The difference goes a little
deeper than that, however. A module is can not run on its
own. It must be loaded into an application, whereas an application can
run on its own. So how is this feature helpful to developers?
Well, first of all, a module can be compiled
separately from the application. This keep developers from having to
recompile an entire application everytime some aspect of functionality changes
within a given feature set. For example, imagine an application that
has 2 features. The first feature is a shopping cart and the second is
a registration form. If the features are compiled into the
application, then if a change were made to the shopping cart.. the entire
application would have to be recompiled. Using modules, however,
allows the developer to only recompile the specific "package"
of functionality for the shopping cart. So the client machines would
still be able to load the main application while the developer worked on
recompiling the shopping cart module and once the module was production ready,
all a developer would have to do is upload the new module to the server and then
the application could call that new module without having any downtime
what-so-ever.
Just think of modules as a nice way of packaging
functionality in discreet containers. Also, if you plan to rebrand
your application, or resell the same application several times, the module
deployment plan allows for certain modules to be loaded per client
need. So think that in the above application, if the customer does not
want a shopping cart, you dont have to change anything in your base
application(if planned correctly) in order to offer seperate ala-carte functions
to entirely different customers. I mean really, who wants to
have a 500K application load everytime a client machine calls the server when
the customer has only purchased 150K worth of deployable product. Trust me... save the bandwidth by calling the modules into the application at
runtime.