none
Designing a "modular" ASP.NET web application RRS feed

  • Question

  • 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

    Anthony

    Saturday, August 4, 2007 1:09 PM

All replies

  • The "web client software factory" has guidance for most of the features you need: http://www.codeplex.com/websf. There is a forum there, where you can post further questions you may have after checking it out.

     

    Regards,

    Freddy

    Saturday, August 4, 2007 4:02 PM
  • Sounds a lot like an implementation of the MVP/MVC pattern.

    The 2 links below have all the information you need on such an implementation. To add a module without recompiling I would use the Spring.NET framework  which you will find a link to in the Wikipedia article.

     

     

    http://en.wikipedia.org/wiki/Model-view-controller

    http://msdn.microsoft.com/msdnmag/issues/06/08/designpatterns/default.aspx

     

    I hope this was helpful, if you need any more info please reply.
    Saturday, August 4, 2007 10:54 PM
  • Thanks for the reply.

    I will look into MVC pattern again but in the past i have looked into it and maybe i didn’t get far enough into it but when i was reading about it, but to me it seemed very much like a n-tier architecture under a different name. Is this perception right, as i said i might not have read enough, but i am pretty sure that what i can remember is that MVC just talks about separation your business logic from the user interface. Is that right in a nut shell, because if it is then to me it is just n-tier and what i am thinking is a level up from there. For example each module would contain a n-tier architecture within it, each module defines a business operation (like client or invoicing or reporting could all be different modules). Does that make sense, but as i said i might have MVC all wrong and i will look at it again anyway but maybe you can help clarify that.

    Thanks

    Anthony

    Sunday, August 5, 2007 4:44 AM
  • MVC is not like n-tier architecture since MVC is a UI architecture. i.e. all the components are in the UI tier and they are not spread on different tiers.
    Two additional UI patterns to look for are Supervising Controller and Passive View (which are basically two variants on the MVP pattern)

    Arnon
    Sunday, August 5, 2007 10:46 AM
  • I agreed with Arnon MVC does not mean that your architecture  is not SOA. Your UI layer can send messages to services that implement the business logic (Business services). So in that sense, because it decouples business logic from UI, it could help you interface with your services in an SOA environment.

     

    Sunday, August 5, 2007 3:21 PM
  •  vdhant wrote:
    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...

    [snip]

    Anthony,

     

    What you suggest sounds oddly like something I did for Windows Services a while back.  You can read more about it here and here.  In brief, I'd say, yeah, you could do something like this to build a plug-in framework on top of what we have with HTTP modules and handlers, though you want to be sure you're adding value over the built-in module/handler functionality to put a middle man in there.  Generally speaking, HTTP modules and handlers are the right/best way to build pluggable ASP.NET functionality that doesn't require modification to the site code itself.  You might also look at the DotNetNuke platform as another example of modular ASP.NET development.

    Monday, August 6, 2007 9:27 PM
  • Hi Ambrose

    I think what you are suggesting is most along the lines of what i am thinking in terms of the pluggable framework - "you could do something like this to build a plug-in framework on top of what we have with HTTP modules and handlers". Plus what you are describing here is what i want to be able to achieve "HTTP modules and handlers are the right/best way to build pluggable ASP.NET functionality that doesn't require modification to the site code itself".

     

    Now i have had some experience with DNN and like the way its modules look, feel and operate (at the surface level anyway, i have not had a chance to dig through all there code to find out how good it actually is, if you know what I mean) and it is this sort of functionality that i am trying to achieve. Now there are a lot of things that come along with DNN that i don’t want or need. Also the modules i am thinking about are more about providing business functionality, so it is something that we are looking to build with this in mind.

     

    The only question that remains is how would one go about building a system like what you have described (excluding the web services part). I haven’t been able to find very much about how to build such a system. For example one of the challenges that i foresee is the following: I am planning to have a core DAL module. In this module i would have series of events that different modules/providers could hook into. An example of this could be a logging module. What i would like to be able to do is to deploy the logging module and DAL module as two different components that don’t know about each other. Thus for the logging module to be able to plug into the DAL module (given the last sentence) i would need to have something that brings the two together some how. How one simply could add some code to the DAL which would wire up the event, but this would mean that i would have to make a code change to the DAL module which would mean that i have just broken the policy that nether should know or have any reference to each other. The event should be brokered by a third party some how. I imagine that this is how it works in DNN, if i want to tap into the the event that fires before the update occurs, it doesn't require (i image anyway) that you would have to recompile the app and add a hard coded change to the framework and you couldn’t put the reference (directly anyway) in the logging module because it doesn’t hold an instance of the DAL object.  

     

    So as you can see I think we are getting very close to working out what I need and I just need a little bit help getting over some of the hurdles (as I don’t think this is a particular easy thing to set up and get running properly) and see if anyone has documented developing such a system/pattern.

    Thanks

    Anthony

     

    Tuesday, August 7, 2007 12:25 PM
  •  vdhant wrote:

    i would need to have something that brings the two together some how.

    Anthony,

     

    You could create a configurable event handler that has a source event and a target type and method (that must match the event's delegate).  You couldn't do compile-time checking on these, but that's what you lose with late binding.  Something like so:

     

    <myModules>

    <add type="MyModuleLoggingType" />

    <add type="MyModuleDalType" />

    </myModules>

    <myEventHandlers>

    <add sourceEvent="MyModuleDalType.DataAccessError" targetType="MyModuleLoggingType" targetHandler="LogError" />

    </myEventHandlers>

     

    As you can imagine, the participants in this case would need to be static.  To work with instances, you'd have to create some sort of object creation factory/pipeline that your objects go through.  But the more I think about all this, the more I wonder if you wouldn't be better off just using EntLib.  It already has all this kind of framework in place. 

     

    The reason you would want to create a plug-in framework modules and handlers is specifically to leverage something in the HTTP application lifetime or to be able to handle Web requests.  If you're talking about building business-level modules, I'd think working with EntLib would be a better option so that you can take advantage of its infrastructure and even use the existing blocks where they apply (such as logging and exception handling).  And there's no reason you couldn't do a hybrid of the two--using modules and handlers where you need to inject into the HTTP pipeline or handle requests and using EntLib behind that for functionality that doesn't require that context.

    Tuesday, August 7, 2007 1:39 PM
  • As J. Ambrose Little points out, you would probably be better off with Enterprise Library. There is already a Loggin Application Block meant for logging.

     

    Once again, I really advise you to look at the "web client software factory" published by the microsoft patterns and practices team: http://www.codeplex.com/websf, since it uses the enterprise library.

     

    The factories are created in order to help teams to use readily available patterns and solutions, that solve this types of scenarios.

     

    Hope this helps,

     

    Freddy Rios

    Tuesday, August 7, 2007 10:56 PM
  • I realise that the enterprise library contains a logging block and it will probably be what i use for this, but i was only using this of an example of what am looking to achieve. Another example of what i might what to do is have an encryption module or a data sensitivity module or anything else that that you can think of along these lines.
     
    I will have a look into the "web client software factory" and see what it has to offer, in terms of having pluggable modules like what i have described. Is there any recourse in particular that goes into the pluggable framework that it has and how to register events/modules/providers etc that you know of?
     
    Also, Ambrose what you have described is along the lines of what i was thinking. The only thing that i was wondering was what would the performance of such a system like this be. In that each time the event fires it would have to go to the config file and see if any methods were registered to tap into the event. It would be good if there was a way that the first time that the DAL event fired or when the whole application runs, there was some way of taking this config settings compiling the code. I have seen some examples of where people create classes dynamically on the fly using CompilerParameters and CompileAssemblyFromSource, not that i am saying that this could be used here but just the idea that once deployed live (or the application restarted) it could be complied and thus not run much different performance wise after the complication has occurred.
     
    When you have said the following, "As you can imagine, the participants in this case would need to be static.  To work with instances, you'd have to create some sort of object creation factory/pipeline that your objects go through." have you seen any examples of where someone has actually attempted to do this and how it turned out. I would imagine that DNN would have to work somewhat like this (although i am not 100% sure). It would be good if there were some examples of this out there that i could look at, evaluate and start to come up with a design of. When i first started thinking of this i thought that there would have been plenty of examples of this, but i have not been able to find all that much. For example, i know of plenty of applications out there (mainly open source ones) that have extreamly good plugable frameworks in them (NetBeans is one that comes to mind). They would have to exspose the different events that occure within the application and allow users to tap into them. 
     
    Also another question i had in regards to the development and management of modules, lets say that i have a core system that hold most of the core application logic (like the BLL and DAL supporting code) and that is deployed. I then start to make a module call client which uses the framework provided by this core application. Now because of the pattern i want to adopt i would have to create a different VS solution to that that holds the core application. This client module VS solution would have to contain references to the core dll's in order to complie and build the application. Now the problems comes when you complete this client module it would (as far as i can tell) want to copy the core dll's that i have referenced into the client module. Thus when i look at the dll's that the client module has it would not only have the modules that are specific to it but a copy of the core dll's. What i would like to see is that it doesn’t have this and that the only dll's that are present are the ones needed for this module. As you can imagine if i have a situation where one module has a dependency of a couple of other modules the amount of dll's that start being put into the project are fairly large and would be hard to maintain. I hope you can see the problem that i am getting at, it not so much a design question but one of managing the various modules that we create.
     
    Thanks for the continued help
    Anthony
    Wednesday, August 8, 2007 9:23 AM
  • Hi what was you decesion , i am finding myself in similar situation. Also does using HttpHandler/HttpModules mean that we have to loose usual webform designer niceties 

    Friday, August 12, 2011 7:02 PM