Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Architecture: Designing a "modular" ASP.NET web application

Posted on 2007-08-01
14
Medium Priority
?
1,030 Views
Last Modified: 2013-11-12
Hi guys
I have not been able to find too many articles that cover this topic and so I was wondering if someone gives me some tips and guidance on this topic...

I would like to be able to build a web application that is made up of server different modules (not a VB module) that can be easily rolled out across different projects. Each module would probably reside in its own individual directory and would add additional functionality, classes, WebPages and database objects/data.

The solution that we come up with should not have to require the recompile of the application to install a new component. If we have a bug fix we want to be able to package up module and redeploy (by an upload manager in the app) it across the different projects.

I would imagine that we would have a base system/platform that contains all the base functionality and the pluming/framework to allow for other modules to be installed and run. It would contain all the base classes for the application framework which the different modules would use. Also due to the complexity of the modules there would probably be dependencies that exist between various modules (i am thinking more at the data layer than cross modular code). And the list goes on.

Also I am thinking of another type of module (like a workflow engine for example) that does not just bring extra page functionality to the site, but could enable other modules to it or take advantage of the code that it exposes to run.

Lastly a third type of module that would plug into different events that the main modules raise. For example we could deploy an auditing system that is run by an event that each of the main modules fire when they attempt to update the database (I image that interfaces would be used here to ensure that the modules have the required events so that the module can plug-in correctly).

So in short I was just wondering if anyone can point me in the right direction as to how about designing such a system. To see what peoples experiences have been like. To see if anyone knows whether there are any tutes, patterns or websites that go into how one would practically pull this off and the problems involved, not just the theory of how nice it would be if you can do this or what it should end up looking like.
Thanks
ant
0
Comment
Question by:vdhant
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 8

Expert Comment

by:Ashutosh Vyas
ID: 19615087
Probably what you are in look out for is MVC ( Model - View - Controller) Archietecture.
Search for MVC archietecture and you would find a lot of tutorials and design patterns regarding the same.

http://www.indiawebdevelopers.com/technology/java/mvcarchitecture.asp

Also there are a few ready made MVC application frameworks out there to build upon.


Hope this helps
0
 
LVL 18

Expert Comment

by:DropZone
ID: 19615695
You can certainly do this with ASP.NET, although it is not the obvious thing when using VisualStudio (as far as I know; I use Delphi.NET).  However, I've done this very thing in my ASP.NET web applications.

Each "module" that you mention would reside on a separate assembly (whcih is a .NET compiled code library, sort of like a DLL).  By intelligently using namespaces, your entire application can be composed of reusable modular assemblies that work in unison.  They would all reside in the /bin directory of your application, but updating one assembly will not affect the others (unless there are interface and other changes from which other assemblies depend).  Basically the assemblies are "hot-swappable", so that you don't even have to restart the application.  And if you set up your application to use SessionStateServer, replacing assemblies (and in fact, restarting the application), won't even affect your users' sessions.

This is pretty much how the .NET framework works itself:  All those DLLs in the framework's directory are assemblies, and some of them share namespaces, although they are independent.  Your applications are free to use some and not others without having to link to the entire set at once.

In my projects, for example, I have the following namespace layout:

CompanyName (our base namespace)

CompanyName.Form
CompanyName.Form.Controls
CompanyName.Form.Controls.Text   (scalar input fields)
CompanyName.Form.Controls.List  (dropdownlists, etc.)
CompanyName.Form.Controls.Misc (checkbox, label, etc.)
CompanyName.Form.Controls.Repeater (custom repeaters and grids)
CompanyName.Form.Controls.Container (collapsible panels, titled containers, etc.)
CompanyName.Form.Page
CompanyName.Form.Constants

CompanyName.Lib
CompanyName.Lib.Data  (data-access layer)
CompanyName.Lib.Crypt  (encryption wrappers)
CompanyName.Lib.Mail   (smtp module)
CompanyName.Lib.Session (user-session information)
CompanyName.Lib.Error (custom exceptions, error handling, logging, etc.)

...(and many more)

As you can see, there's a namespace for custom form controls (Form) and a namespace for general code libraries (Lib).  In the case of Form, it is grouped into "Page" and "Controls", and each of these resides in a different assembly.  That way, if I need to update, extend, or fix, say, a text input control, I recompile only the Form assembly and do not affect the others.

In the case of the Lib namespace, some of the sub parts are individual assemblies, the ones that are recognized as "stand alone", such as Lib.Data.

Alternatively, each namespace could be enclosed in a single assembly to ensure that dependencies are retained and followed properly.

This way I can reuse most or all these llibraries in my web applications, using a single common code-base without having to re-compile the entire thing every time.  And most importantly, the bulk of the processing code is completely independent and abstracted from the presentation layer, therefore following the MVC model that ashutosh mentioned above.

     I hope this helps.
     Cheers!
      -dZ.
0
 
LVL 2

Author Comment

by:vdhant
ID: 19616008
Hi guys thanks for the replies.
What you have described dZ seems to be more along the lines of what i am trying to do and at a low level probably is. But i am talking more about the concept that i can drop in a module like client, ordering, products, etc and with the addition of each module the system would gain this functionality. Then within each module there would be the pages that each one needs, code that they require, images, database update scripts, etc. This means that i could have a core application that by its self may have very little (as far as user functionality is concerned), but it gives me the means to include these different components in any fashion i require. These modules themselves would implement the MVC pattern within them, these modules would be a layer up from were MVC presides.

Now with what you have mentioned, it would enable me to do an update to the form control and update it (which is a part of what i am trying to achieve), but i am trying to get closer to the point were the modules represent business concepts.

Also with what you have got, it seems that the dll up are replacing were already a part of the system to start with. What happens if you have designed a new auditing/logging component, is this something that you can just drop in without any changes.

The system i am looking at should be able to see that there is the new dll sitting here that is trying to attach to this particular event and be able to cope with that. Also for it to see that there is a new client module that has just been added and for it to work.

I hope that gives you a better idea of what i am after.
Thanks
ant
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 37

Expert Comment

by:samtran0331
ID: 19616161
You might want to look into something like DotNetNuke
http://www.dotnetnuke.com

It's technically a portal application, but you can develop modules that "plug in" to their existing framework.
DNN is opensource and highly customizable and I think it is in line with what you are trying to do.
0
 
LVL 18

Expert Comment

by:DropZone
ID: 19617948
>> QUOTE: Now with what you have mentioned, it would enable me to do an update to the form control and update it (which is a part of what i am trying to achieve), but i am trying to get closer to the point were the modules represent business concepts.

My example is not exhaustive, and only represents a very small subset of my framework.  I do have business logic modules and the like, some of which are generic for all applications, and some of which are specific per application.  They can share the namespace but be independent.  I just gave you that list as an example of dividing modules into a comprehensive namespace, independent of their physical location, following the MVC approach.

>> QUOTE: Also with what you have got, it seems that the dll up are replacing were already a part of the system to start with. What happens if you have designed a new auditing/logging component, is this something that you can just drop in without any changes.

By all means.  Any of your assemblies can just be "dropped in" to replace their previous version and the application will continue working as usual (except that it will be restarted automatically once all current requests are completed, to dynamically link the new assembly).  This has nothing to do with replacing framework components or implementing new code, it is just the mechanism that the ASP.NET framework uses to dynamically link assemblies.

>> QUOTE: But i am talking more about the concept that i can drop in a module like client, ordering, products, etc and with the addition of each module the system would gain this functionality.

As long as you implement these modules using the MVC pattern, you can do just that.  Like I mention before, this is not the obvious approach promoted by VisualStudio and many examples, since it seems to be encouraged that you implement business logic as part of the Page or any other custom visual control itself; or at least that's what I've seen commonplace.  That said, it is perfectly supported by the framework, and it is in fact a better approach for scalable and reusable applications, and indeed my pattern of choice.

>> QUOTE: The system i am looking at should be able to see that there is the new dll sitting here that is trying to attach to this particular event and be able to cope with that. Also for it to see that there is a new client module that has just been added and for it to work.

The ASP.NET framework was designed with this in mind: to avoid the headaches from the Classic ASP days where you had to shutdown IIS, unregister old COM components, register new ones, and then start IIS back again; meanwhile your users lose access to your application.  In ASP.NET, all binary assemblies reside in the /bin directory of the application, and get dynamically loaded every time an instance of your application is started.  And they are monitored automatically, so that when any of them are changed (actually, I believe its when their timestamp changes), the framework will terminate all running instances of your application, but will wait until their currently active requests are processed.  Then as soon as the next request is made, the framework will link dynamically all assemblies.  All this is transparent to the user, who will get the benefit of the changes immediately on his next request after the update.  No need to register/unregister DLLs, no need to shutdown the web server.

For the sake of completion, I will mention that there is also an application configuration file (Web.Config), which is monitored in the same way, and as soon as its timestamp changes, the application is restarted in the same way.

As for adding new modules, well, you can drop in as many new ones as you like, and the moment they get requested by the application, they will be dynamically linked automatically and transparently as above.

The only hitch is that user sessions will be lost, if the sessions are kept "in-process", which is the default.  This can be corrected, as I mentioned in my previous message, by using SessionStateServer, which will keep user sessions alive while the application is restarted.

I hope this helps in answering your questions.

    Cheers!
    -dZ.
0
 
LVL 2

Author Comment

by:vdhant
ID: 19620594
Hi guys
 dZ i will reply to your post soon (i dont have time now), but samtran0331 i have used DNN before and i guess the sort of application model if provides is what i am after creating. For the purposes of this exercise i would prefer not to use a system that is already built, but i am happy to see what they have done and come up with something specific for our problem. For example, the module definition that they have and the provider pattern that they are using is really what i am wanting to implement in our system. But in saying that i guess i am looking for documentation on how they have gone about this and what could have been improved etc. Also there is more than DNN out there, so i guess i was after someone who has gone through and architected these sorts of system and hopefully gain a bit of insight into the difficulties that they faced and the things they did, etc, etc. I think you see what i am getting at.
Thanks
ant
0
 
LVL 2

Author Comment

by:vdhant
ID: 19622208
Hi dZ
What you have said is interesting. Do you have an overall controller with the base app that you use to control the deployment and management of the different modules and do you have a core part within your framework that exposes the different base functionality that the system requires.

Also from what you have described, because of the way asp.net intrinsically works do you have much of a need to use reflection or anything similar to dynamically link in the different parts of the module.

Lastly this is a vision that i am thinking of at the movement, do you think that this would be possible with what we have discussed at the moment:

I would have two main different thing, modules and providers (note this mightn't necessarily the same thing as a .net provider or though it might end up being so):
Module -
> This represents a defined block of business logic
> Dependences may exist between the different modules and other providers
> A module might contain user interface controls (pages, ui controls, etc), a code library specific to the modular, SQL scripts (install and uninstall sql scripts for the module), a manifest or whats included, a contract (dependences, etc), relevant help files, images, etc

Providers -
> This is less of a concrete thing than a modular and probably would not represents items in the business domain
> There are two types of providers active and passive
   # Active providers represent classes/components that has hard coded references to it from other modules/providers
   # Passive providers would hook into the different events that are exposed by other providers and within the core framework

Does this all make sense. This is what I am think that I would like to do. The different modules would take advantage of the MVC pattern and would use an n-tier architecture but as I have said I am trying to come up a level.

Let me know what you think
ant
0
 
LVL 18

Expert Comment

by:DropZone
ID: 19623721
I'm afraid I may have misrepresented my approach.  What you seem to be describing in your comments appears close to, say, a JBoss server with servlets running per application, where a centralize controller ultimately processes all requests.  This is not what I have built using .NET, although I don't see why it wouldn't be possible.  What I have built is a framework of classes, separated in discreet namespaces, that can be extended and reused among all my applications.  This framework of classes comprise everything from business logic, to data access, to presentation components.  At the core of each application is its own ApplicationEngine, basically a deterministic finite-state-machine that handles the requests for the application.  This engine is specific to each application, though it is too decended from a common class which exposes the basic functionality.

So in essence, my approach is more of a programmatic framework, exposing a common, reusable, and extensible library of classes, that exploit thoroughly polymorphism and inheritance.  In my approach, dropping in a new module in the application will not do much, as being new, none of the existing ones would know of it.  I tend to shy away from using reflection to discover members of an object (though I've had to use it at times); I prefer to build a more abstract model, using interfaces.

All this follows strictly the Model-View-Controller approach, by completely decoupling the presentation components from the business logic and the data access modules, the AppEngine being the controller at the core.

I think that your approach is sound, and is perfectly workable with the .NET framework.  It depends on your needs of course, and that's the reason that mine is different:  I work for a payment processing company, and so far I haven't the need to have providers or the like serving my applications with common services, just common classes and code.  This is the main difference between your description and my design: where you will use providers, I use custom AppEngines classes, but still independent applications.

     I hope this clarifies my comments.
    Cheers!
    -dZ.

     -dZ.
0
 
LVL 2

Author Comment

by:vdhant
ID: 19629440
Thanks for your reply dZ
I think you are now more on the lines of what i am thinking about. I think from what i have been able to tell from your approach, that I am just trying to do what you have done but take it a step further and introduce another layer of abstraction. Do you know of any resources that would go into how to develop/design such a system (preferably under .net).

The biggest thing that i have been wondering is that I guess each one of these different providers/modules would be created in their own solution within VS which is fine, but how do i handle the referencing between the different solutions. For example lets say that I am creating a provider that is designed to listen for different events that are created by another module/provider how I would handle the referencing. I know that once its on the actual server it will work all together, but I development I want to make reference to interfaces/abstract classes in other solutions. Now I know you can do this, but i dont want the new solution that I create to pull over the dll's from the other solution into it to have to run/build the app. I guess its kind of like when you reference a class in the .net framework its doesn't pull the dll from framework down into the solution.

But i guess my question is a more general one of how when you have all these logically separated solutions would you handle referencing.
Thanks ant
0
 
LVL 2

Author Comment

by:vdhant
ID: 19629443
Also i guess, is there a specific model/pattern that what this is that i am trying to do fits into so that i can be a bit more successful in trying to find recourses.
0
 
LVL 18

Expert Comment

by:DropZone
ID: 19630557
I understand what you are saying, and I guess that would be more of a VisualStudio issue, and I'm afraid I can't help you there, for I do not use VisualStudio; I use Delphi 2006 for .NET.  Also, in my model, all re-used code is referenced at design-time (since I don't use external services), and so I can have the luxury of copying the DLLs and linking them at compile time.

About the pattern, I believe it still falls under the MVC (Model-View-Controller) pattern.  I performed a Google search for the term "asp.net mvc application" and the results seem encouraging.  However, keep in mind that -- as I've said many times -- this is not the most intuitive or common approach in .NET:  The problem is that .NET is being refined for quick-and-easy solutions, and drag-and-drop application building, and so many of the examples you'll find will point away from the MVC pattern.  That said, it does offer the ability to do what you want to do, though perhaps not as natural as, say, J2EE.

So, consider very well what you need and what .NET offers.  Take a trip down MSDN and search into distributed ASP.NET applications and all that, and make sure it will do what you need before you commit to any framework.

I know that our organization now regrets choosing .NET as our platform, but our reasons are varied and complex.  I personally think that, though the Event-Driven paradigm embodied in ASP.NET seems slick and simple in theory as a way to abstract the stateless HTTP request-response cycle, in practice its broken and completely unfit for high performance, complex applications.   After having to immerse deep into the murky waters of low-level server control development and having to waddle through the many intricacies of the Page life-cycle, I clamor for the plain old command-driven model.

The .NET framework is very nice and powerful, and offers many good things, but I hear there are other frameworks out there designed for people that, like you and me, want a more hands-on approach to their code.

     -dZ.
0
 
LVL 18

Accepted Solution

by:
DropZone earned 750 total points
ID: 19822072
TheLearnedOne,
I recommend a split between me and ashutosh9910, for providing helpful answers and guidance in response to the original question.

     -dZ.
0
 
LVL 8

Assisted Solution

by:Ashutosh Vyas
Ashutosh Vyas earned 750 total points
ID: 19830058
I back that up. :)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Many of the most common information processing tasks require sorting data sets.  For example, you may want to find the largest or smallest value in a collection.  Or you may want to order the data set in numeric or alphabetical order. …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question