Re: nTier ASP.NET MVC Application Architecture
My 2 Cents... This seems over-engineered. If I were designing this.. I would create new WCF services/ web api controllers for the mobile clients and remove the WCF middle tier. Stacy Andrews (first time poster, long time reader ;)) - Original Message - From: ozDotNet To:ozDotNet Cc: Sent:Wed, 20 Mar 2013 12:27:45 +1000 Subject:Re: nTier ASP.NET MVC Application Architecture Thanks for comments and advice Nathan.. Your idea of DAL between WCF Service and MVC Controllers is a good one, and it does mimic how i have this set up currently (not explained properly previously - sorry).. I have my wcf services accessible only from within my SessionRepository objects. So the controller interacts only with the SR's and the SR talks to the WCF services. Comments on abolishing wcf layer seem sound, I was looking into the dual interfaces to the business layer (1 from mobile and 1 from mvc web). I haven't had the opportunity to explore Web API yet, but it looks like that opportunity has just presented itself.. fyi.. ViewModels packaged in same dll as models (for convenience).. not used in wcf services or as a DTO.. I agree with your _never_ sentiments.. thanks again.. Grant On Wed, Mar 20, 2013 at 11:35 AM, Nathan Schultz wrote: The last time I wrote an MVC app which included an iPhone client, the architecture looked similar to yours. Although I would _never_ have a view model in the WCF project, since a View Model has everything to do with presentation, and nothing to do with data access. I always have a Mapper in the MVC project that maps all Models to View Models and vice-versa. I also consider a web-service really to be just another data repository, so I add a DAL in between the MVC Controller and WCF service. This means a controller is never tied to the web-service, so is independent of implementation. Now that MVC4 has the Web API available, I'd be tempted to abolish the WCF layer so controllers talk directly to the Business Layer. I would then just write Web API controllers that would service RESTful requests from a mobile client. This has the advantage of not having to share a DLL containing your Domain Types and enums. Regards, Nathan. On 20 March 2013 08:11, Grant Molloy wrote: Hi All.. Application architecture is an interesting and regularly debated topic among developers.. Everyone seems to have their own take on it based either purely on theory, real world experiences, and as always, a mixture of both. The application started out as a simple enough hosted ASP.NET [3] MVC application where users would visit a website, register, log in, and work online.. Simple enough.. Recently there's been a change where the scope has creeped with an eye for the future, maximise code re-use, etc.. Fair enough.. Great concept.. My dilemma now is what's the best architecture for this app now that we will be (in the future -- when ever that gets here) accessing the system from mobile devices, and probably not through the default ASP.NET [4] MVC interface that is currently being developed. I've been looking around for a decent online example of an nTier ASP.NET [5] MVC application architecture, but most of the things I've found are all basically single tier where the author accesses the database via DAL directly from controllers. The app has morphed into the following Architecture... --- ASP.NET [6] MVC --- | View | + -- MVC Helpers | | | Model | | | Controller | + -- Constants, Enums Helpers.. (Separate DLL) | + -- Session Repository (in MVC Project) | + -- Domain Types (Models ViewModels) (Separate DLL) --- --- --- --- --- / | WCF Service Call... / --- WCF Services SERVER --- | WCF Services | | | Business Layer | | | DAL | + -- Domain Types (Models ViewModels) (Separate DLL) [.. this is the same dll as referenced by the Controller above] | + -- Constants, Enums Helpers.. (Separate DLL) [.. this is the same dll as referenced by the Controller above] --- --- --- --- --- | --- DATABASE Server --- | Database --- --- --- --- --- This architecture seems to be working fine for now and I know that i'm probably going to have to change my WCF services to use a more RESTful approach, or implement another more mobile friendly interface, to make it easier for mobile connection, but that can happen down the track when i'm ready for that part. I'm also looking to use SQL CLR Types in the future so that I can be sure that the data in reference tables (like say PhoneType, PencilType, CarBrand, etc) mirror that exactly as in the Enums in the code. I've done some preliminary investigations into this and it is feasible, but whether it's worth it is another issue. How are people designing their ASP.NET [7
Re: nTier ASP.NET MVC Application Architecture
I agree. I see WCF middle tier is used so often for no good reason. I would just create an MVC Web API controllers for the mobile app (and future other clients) and have logical tiers, not physical, for business logic. On Wed, Mar 20, 2013 at 7:27 PM, stacy.andr...@iinet.net.au wrote: My 2 Cents... This seems over-engineered. If I were designing this... I would create new WCF services/ web api controllers for the mobile clients and remove the WCF middle tier. Stacy Andrews (first time poster, long time reader ;)) - Original Message - From: ozDotNet ozdotnet@ozdotnet.com To: ozDotNet ozdotnet@ozdotnet.com Cc: Sent: Wed, 20 Mar 2013 12:27:45 +1000 Subject: Re: nTier ASP.NET MVC Application Architecture Thanks for comments and advice Nathan. Your idea of DAL between WCF Service and MVC Controllers is a good one, and it does mimic how i have this set up currently (not explained properly previously - sorry).. I have my wcf services accessible only from within my SessionRepository objects. So the controller interacts only with the SR's and the SR talks to the WCF services. Comments on abolishing wcf layer seem sound, I was looking into the dual interfaces to the business layer (1 from mobile and 1 from mvc web). I haven't had the opportunity to explore Web API yet, but it looks like that opportunity has just presented itself.. fyi.. ViewModels packaged in same dll as models (for convenience).. not used in wcf services or as a DTO.. I agree with your _never_ sentiments.. thanks again.. Grant On Wed, Mar 20, 2013 at 11:35 AM, Nathan Schultz milish...@gmail.comwrote: The last time I wrote an MVC app which included an iPhone client, the architecture looked similar to yours. Although I would _never_ have a view model in the WCF project, since a View Model has everything to do with presentation, and nothing to do with data access. I always have a Mapper in the MVC project that maps all Models to View Models and vice-versa. I also consider a web-service really to be just another data repository, so I add a DAL in between the MVC Controller and WCF service. This means a controller is never tied to the web-service, so is independent of implementation. Now that MVC4 has the Web API available, I'd be tempted to abolish the WCF layer so controllers talk directly to the Business Layer. I would then just write Web API controllers that would service RESTful requests from a mobile client. This has the advantage of not having to share a DLL containing your Domain Types and enums. Regards, Nathan. On 20 March 2013 08:11, Grant Molloy graken...@gmail.com wrote: Hi All.. Application architecture is an interesting and regularly debated topic among developers.. Everyone seems to have their own take on it based either purely on theory, real world experiences, and as always, a mixture of both. The application started out as a simple enough hosted ASP.NET MVC application where users would visit a website, register, log in, and work online.. Simple enough.. Recently there's been a change where the scope has creeped with an eye for the future, maximise code re-use, etc.. Fair enough.. Great concept.. My dilemma now is what's the best architecture for this app now that we will be (in the future -- when ever that gets here) accessing the system from mobile devices, and probably not through the default ASP.NET MVC interface that is currently being developed. I've been looking around for a decent online example of an nTier ASP.NET MVC application architecture, but most of the things I've found are all basically single tier where the author accesses the database via DAL directly from controllers. The app has morphed into the following Architecture... --- ASP.NET MVC --- | View |+ -- MVC Helpers || | Model || | Controller |+ -- Constants, Enums Helpers.. (Separate DLL) |+ -- Session Repository (in MVC Project) |+ -- Domain Types (Models ViewModels) (Separate DLL) --- --- --- --- --- \/ | WCF Service Call... /\ --- WCF Services SERVER --- | WCF Services || | Business Layer || | DAL |+ -- Domain Types (Models ViewModels) (Separate DLL) [.. this is the same dll as referenced by the Controller above] |+ -- Constants, Enums Helpers.. (Separate DLL) [.. this is the same dll as referenced by the Controller above] --- --- --- --- --- | --- DATABASE Server --- | Database --- --- --- --- --- This architecture seems to be working fine for now and I know that i'm probably going to have to change my WCF services to use a more RESTful approach, or implement another more mobile friendly interface, to make it easier for mobile connection, but that can happen down the track when i'm
Re: nTier ASP.NET MVC Application Architecture
Thanks to everyone who's taken the time to read, consider and reply. The consensus seems to be MVC4 Web API. I think i will take that advice and upgrade to MVC4. I know www.asp.net is a good starting point but does anyone have some super must use web resource for MVC4 (to save hours on Google)? Has anyone had any experience in scaling up and out using MVC4 ? Anything special need doing, or considered early? How easy was it? How is it performing? Thanks again Grant On Mar 20, 2013 10:22 PM, Craig van Nieuwkerk crai...@gmail.com wrote: I agree. I see WCF middle tier is used so often for no good reason. I would just create an MVC Web API controllers for the mobile app (and future other clients) and have logical tiers, not physical, for business logic. On Wed, Mar 20, 2013 at 7:27 PM, stacy.andr...@iinet.net.au wrote: My 2 Cents... This seems over-engineered. If I were designing this... I would create new WCF services/ web api controllers for the mobile clients and remove the WCF middle tier. Stacy Andrews (first time poster, long time reader ;)) - Original Message - From: ozDotNet ozdotnet@ozdotnet.com To: ozDotNet ozdotnet@ozdotnet.com Cc: Sent: Wed, 20 Mar 2013 12:27:45 +1000 Subject: Re: nTier ASP.NET MVC Application Architecture Thanks for comments and advice Nathan. Your idea of DAL between WCF Service and MVC Controllers is a good one, and it does mimic how i have this set up currently (not explained properly previously - sorry).. I have my wcf services accessible only from within my SessionRepository objects. So the controller interacts only with the SR's and the SR talks to the WCF services. Comments on abolishing wcf layer seem sound, I was looking into the dual interfaces to the business layer (1 from mobile and 1 from mvc web). I haven't had the opportunity to explore Web API yet, but it looks like that opportunity has just presented itself.. fyi.. ViewModels packaged in same dll as models (for convenience).. not used in wcf services or as a DTO.. I agree with your _never_ sentiments.. thanks again.. Grant On Wed, Mar 20, 2013 at 11:35 AM, Nathan Schultz milish...@gmail.comwrote: The last time I wrote an MVC app which included an iPhone client, the architecture looked similar to yours. Although I would _never_ have a view model in the WCF project, since a View Model has everything to do with presentation, and nothing to do with data access. I always have a Mapper in the MVC project that maps all Models to View Models and vice-versa. I also consider a web-service really to be just another data repository, so I add a DAL in between the MVC Controller and WCF service. This means a controller is never tied to the web-service, so is independent of implementation. Now that MVC4 has the Web API available, I'd be tempted to abolish the WCF layer so controllers talk directly to the Business Layer. I would then just write Web API controllers that would service RESTful requests from a mobile client. This has the advantage of not having to share a DLL containing your Domain Types and enums. Regards, Nathan. On 20 March 2013 08:11, Grant Molloy graken...@gmail.com wrote: Hi All.. Application architecture is an interesting and regularly debated topic among developers.. Everyone seems to have their own take on it based either purely on theory, real world experiences, and as always, a mixture of both. The application started out as a simple enough hosted ASP.NET MVC application where users would visit a website, register, log in, and work online.. Simple enough.. Recently there's been a change where the scope has creeped with an eye for the future, maximise code re-use, etc.. Fair enough.. Great concept.. My dilemma now is what's the best architecture for this app now that we will be (in the future -- when ever that gets here) accessing the system from mobile devices, and probably not through the default ASP.NET MVC interface that is currently being developed. I've been looking around for a decent online example of an nTier ASP.NET MVC application architecture, but most of the things I've found are all basically single tier where the author accesses the database via DAL directly from controllers. The app has morphed into the following Architecture... --- ASP.NET MVC --- | View |+ -- MVC Helpers || | Model || | Controller |+ -- Constants, Enums Helpers.. (Separate DLL) |+ -- Session Repository (in MVC Project) |+ -- Domain Types (Models ViewModels) (Separate DLL) --- --- --- --- --- \/ | WCF Service Call... /\ --- WCF Services SERVER --- | WCF Services || | Business Layer || | DAL |+ -- Domain Types (Models ViewModels) (Separate DLL) [.. this is the same dll as referenced by the Controller above] |+ -- Constants
Re: nTier ASP.NET MVC Application Architecture
IMO, the key to scaling out always starts with making your app stateless. Don't use Session. Then you can essentially just keep adding as many load balanced web servers as you need. But unless you have mega traffic, a couple of servers will handle a lot. Scaling out databases is a whole different story and depends a lot on your application reqirements. Has anyone had any experience in scaling up and out using MVC4 ? Anything special need doing, or considered early? How easy was it? How is it performing?
RE: nTier ASP.NET MVC Application Architecture
Hi Greg, as well as the fat books, you may find the Pluralsight MVC videos helpful too... Cheers, Jason
Re: nTier ASP.NET MVC Application Architecture
What would you do without your suffering? I converted my wife's website from dotnetnuke to an MVC4 website. Most of the site was just static pages but I wanted to have the ability to publish forsale and forrent for properties. (Real estate site). I have it up on Azure and am using code first so it creates the database schema etc. Only issue I hit was a little bit of messing about getting the migrate stuff to happen automatically when I published it to Azure. Other than that I was pleased with how much cleaner things felt when compared with the Asp.net world you so accurately described. I actually avoided the web world as much as I could due to the development experience. Now, I can actually see myself working with it and am learning Javascript, as well as updating my html/css skills to the latest and greatest. Its a much richer web world now (in the UI/UX sense) which is what put me off and sent me to the xaml world. I don't see it as something to be actively avoided now. On Thu, Mar 21, 2013 at 6:36 AM, Greg Keogh g...@mira.net wrote: This discussion comes at a coincidentally interesting time for me, as over recent years I have become increasingly irritated by classic ASP.NET. The controls are just so heavyweight and the lifecycle of events and postbacks is so tangled that you need a doctorate in topology to follow it. All of the problems I have ever suffered usually boil down to fighting or misunderstanding the huge infrastructure that wraps up such a simple concept as a http request. Lord knows how many times I've made a subtle mistake in Load, CreateChildControls, PreRender, Render, event handlers, etc, causing composite controls or repeater controls to produce gibberish. And then there is the misery of trying to integrate JavaScript into the machinery. I was just about to visit bookware and buy two fat ASP.NET MVC 4 books, obviously because I'm considering that as an alternative. I've read about the differences between the frameworks and I've run some tutorials and can see immediately that MVC takes you closer to the wire and gives you more control over rendering, with the penalty that you have to do more work. So I'm wondering if there is anyone here who has migrated to MVC 3/4 successfully and happily? Is it just substituting one huge complex framework for another huge complex one which simply changes the problems from one set to another? I worry about the number of files in a large MVC project. Are there tools or techniques to integrate scripting more easily? What about emitting html that is cross-browser safe or standards compliant? Will MVC make these things easier than in class ASP.NET? Should I give up on ASP.NET completely and use something like the GTK or the confusing family of similar tools to use html5? Can I leave the ASP.NET world totally behind and go this way for rich and interactive web sites? Has anyone gone this way? Is it just a new form of suffering? Greg K
Re: nTier ASP.NET MVC Application Architecture
@Greg, IMHO, unless you are practising Test Driven Design, I do not believe MVC is a necessarily silver bullet over normal ASP.NET. It's still cleaner, but often there are things that are easier to do in normal ASP.Net. If you do practice TDD though, it's an absolute god-send. Yes, while there are more files in MVC, each has only a single intent and so are small and easy to understand. This is different than the mega-long entangled code-behind pages you often find in standard ASP.NET which often contain everything including the kitchen sink. Overall the amount of code is about the same. I learned MVC the same way I normally learn things: watched a couple of videos on Channel 9 MSDN so I understood the basics. And then I jumped right in and wrote a pet-project in it, and looked up topics as I need them. I do know one guy who went from ASP.Net to MVC and hated it. MVC just didn't click for him. Long story short, he got into Ruby On Rails development soon after, and this caused all of the MVC pieces to fall into place for him. Now he prefers MVC and sings its praises. I've written a couple of commercial intranet sites in MVC3 - but both have been fairly small. Usually all of the larger sites I do all tend to be based in SharePoint - simply because that is the infrastructure that tends to be in place in large companies. I don't see any reason why MVC wouldn't scale well. On 21 March 2013 09:02, Stephen Price step...@perthprojects.com wrote: What would you do without your suffering? I converted my wife's website from dotnetnuke to an MVC4 website. Most of the site was just static pages but I wanted to have the ability to publish forsale and forrent for properties. (Real estate site). I have it up on Azure and am using code first so it creates the database schema etc. Only issue I hit was a little bit of messing about getting the migrate stuff to happen automatically when I published it to Azure. Other than that I was pleased with how much cleaner things felt when compared with the Asp.net world you so accurately described. I actually avoided the web world as much as I could due to the development experience. Now, I can actually see myself working with it and am learning Javascript, as well as updating my html/css skills to the latest and greatest. Its a much richer web world now (in the UI/UX sense) which is what put me off and sent me to the xaml world. I don't see it as something to be actively avoided now. On Thu, Mar 21, 2013 at 6:36 AM, Greg Keogh g...@mira.net wrote: This discussion comes at a coincidentally interesting time for me, as over recent years I have become increasingly irritated by classic ASP.NET. The controls are just so heavyweight and the lifecycle of events and postbacks is so tangled that you need a doctorate in topology to follow it. All of the problems I have ever suffered usually boil down to fighting or misunderstanding the huge infrastructure that wraps up such a simple concept as a http request. Lord knows how many times I've made a subtle mistake in Load, CreateChildControls, PreRender, Render, event handlers, etc, causing composite controls or repeater controls to produce gibberish. And then there is the misery of trying to integrate JavaScript into the machinery. I was just about to visit bookware and buy two fat ASP.NET MVC 4 books, obviously because I'm considering that as an alternative. I've read about the differences between the frameworks and I've run some tutorials and can see immediately that MVC takes you closer to the wire and gives you more control over rendering, with the penalty that you have to do more work. So I'm wondering if there is anyone here who has migrated to MVC 3/4 successfully and happily? Is it just substituting one huge complex framework for another huge complex one which simply changes the problems from one set to another? I worry about the number of files in a large MVC project. Are there tools or techniques to integrate scripting more easily? What about emitting html that is cross-browser safe or standards compliant? Will MVC make these things easier than in class ASP.NET? Should I give up on ASP.NET completely and use something like the GTK or the confusing family of similar tools to use html5? Can I leave the ASP.NET world totally behind and go this way for rich and interactive web sites? Has anyone gone this way? Is it just a new form of suffering? Greg K
RE: nTier ASP.NET MVC Application Architecture
Hi Craig, Agreed but what intrigues me (or frustrates me) is the real differences in even very basic functionality. Even sadder are things like it being 2013 and there’s still no common video format that you can use, etc. Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 mobile│ +61 3 8676 4913 fax SQL Down Under | Web: http://www.sqldownunder.com/ www.sqldownunder.com From: Craig van Nieuwkerk [mailto:crai...@gmail.com] Sent: Thursday, 21 March 2013 12:25 PM To: g...@greglow.com; ozDotNet Subject: Re: nTier ASP.NET MVC Application Architecture Getting things to look good on all browsers takes a bit of experience. I think the keys are - Don't support old browsers (IE6) unless you really have to - Remember that it doesn't have to look exactly the same on every browser. If IE8 doesn't support gradients for example, they don't get them. - Use common frameworks like Twitter Bootstrap and jQuery that do a lot of work abstracting the change out for you. On Thu, Mar 21, 2013 at 12:10 PM, Greg Low (GregLow.com) g...@greglow.com mailto:g...@greglow.com wrote: Yep, found the same. They were very useful. Now if browsers would only all play the game properly, it’d be pretty easy. I still find real challenges trying to get things to look even close to the same on the different browsers, even with trying different toolkits. Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 tel:%2B61%20419201410 mobile│ +61 3 8676 4913 tel:%2B61%203%208676%204913 fax SQL Down Under | Web: http://www.sqldownunder.com/ www.sqldownunder.com From: ozdotnet-boun...@ozdotnet.com mailto:ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com mailto:ozdotnet-boun...@ozdotnet.com ] On Behalf Of Jason Roberts Sent: Thursday, 21 March 2013 10:31 AM To: ozDotNet Subject: RE: nTier ASP.NET http://ASP.NET MVC Application Architecture Hi Greg, as well as the fat books, you may find the Pluralsight MVC videos helpful too... Cheers, Jason _ From: Greg Keogh Sent: 21/03/2013 6:36 AM To: ozDotNet Subject: Re: nTier ASP.NET http://ASP.NET MVC Application Architecture This discussion comes at a coincidentally interesting time for me, as over recent years I have become increasingly irritated by classic ASP.NET http://ASP.NET . The controls are just so heavyweight and the lifecycle of events and postbacks is so tangled that you need a doctorate in topology to follow it. All of the problems I have ever suffered usually boil down to fighting or misunderstanding the huge infrastructure that wraps up such a simple concept as a http request. Lord knows how many times I've made a subtle mistake in Load, CreateChildControls, PreRender, Render, event handlers, etc, causing composite controls or repeater controls to produce gibberish. And then there is the misery of trying to integrate JavaScript into the machinery. I was just about to visit bookware and buy two fat ASP.NET http://ASP.NET MVC 4 books, obviously because I'm considering that as an alternative. I've read about the differences between the frameworks and I've run some tutorials and can see immediately that MVC takes you closer to the wire and gives you more control over rendering, with the penalty that you have to do more work. So I'm wondering if there is anyone here who has migrated to MVC 3/4 successfully and happily? Is it just substituting one huge complex framework for another huge complex one which simply changes the problems from one set to another? I worry about the number of files in a large MVC project. Are there tools or techniques to integrate scripting more easily? What about emitting html that is cross-browser safe or standards compliant? Will MVC make these things easier than in class ASP.NET http://ASP.NET ? Should I give up on ASP.NET http://ASP.NET completely and use something like the GTK or the confusing family of similar tools to use html5? Can I leave the ASP.NET http://ASP.NET world totally behind and go this way for rich and interactive web sites? Has anyone gone this way? Is it just a new form of suffering? Greg K
Re: nTier ASP.NET MVC Application Architecture
Nathan, You can do TDD even in web forms, have a look at WebForms MVP project it helps with the separation - http://webformsmvp.com/ - http://blog.tatham.oddie.com.au/ HTH, Filip Regards, Filip Kratochvil mob. 0438 001 110 http://www.dataconversions.com.au/ On 21 March 2013 14:36, Nathan Schultz milish...@gmail.com wrote: Have you guys ever checked out Modernizr (http://modernizr.com/)? When it comes to browser compatibility there not only several browsers to support, but the platform makes a difference too (e.g. a mobile platform isn't necessarily fully featured). What Modernizr does is test the browser for what features it supports, and where a feature is missing you decide whether you want to: - Do without (i.e. rounded corners might not be important) - Use a 'PolyFill' which is some java-script that 'fakes' the feature - Find your own way around using CSS It's not perfect, but it does make life a lot easier. On 21 March 2013 10:36, Greg Low (GregLow.com) g...@greglow.com wrote: Hi Craig, Agreed but what intrigues me (or frustrates me) is the real differences in even very basic functionality. Even sadder are things like it being 2013 and there’s still no common video format that you can use, etc. Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 mobile│ +61 3 8676 4913fax SQL Down Under | Web: www.sqldownunder.com From: Craig van Nieuwkerk [mailto:crai...@gmail.com] Sent: Thursday, 21 March 2013 12:25 PM To: g...@greglow.com; ozDotNet Subject: Re: nTier ASP.NET MVC Application Architecture Getting things to look good on all browsers takes a bit of experience. I think the keys are - Don't support old browsers (IE6) unless you really have to - Remember that it doesn't have to look exactly the same on every browser. If IE8 doesn't support gradients for example, they don't get them. - Use common frameworks like Twitter Bootstrap and jQuery that do a lot of work abstracting the change out for you. On Thu, Mar 21, 2013 at 12:10 PM, Greg Low (GregLow.com) g...@greglow.com wrote: Yep, found the same. They were very useful. Now if browsers would only all play the game properly, it’d be pretty easy. I still find real challenges trying to get things to look even close to the same on the different browsers, even with trying different toolkits. Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 mobile│ +61 3 8676 4913fax SQL Down Under | Web: www.sqldownunder.com From: ozdotnet-boun...@ozdotnet.com [mailto: ozdotnet-boun...@ozdotnet.com] On Behalf Of Jason Roberts Sent: Thursday, 21 March 2013 10:31 AM To: ozDotNet Subject: RE: nTier ASP.NET MVC Application Architecture Hi Greg, as well as the fat books, you may find the Pluralsight MVC videos helpful too... Cheers, Jason From: Greg Keogh Sent: 21/03/2013 6:36 AM To: ozDotNet Subject: Re: nTier ASP.NET MVC Application Architecture This discussion comes at a coincidentally interesting time for me, as over recent years I have become increasingly irritated by classic ASP.NET. The controls are just so heavyweight and the lifecycle of events and postbacks is so tangled that you need a doctorate in topology to follow it. All of the problems I have ever suffered usually boil down to fighting or misunderstanding the huge infrastructure that wraps up such a simple concept as a http request. Lord knows how many times I've made a subtle mistake in Load, CreateChildControls, PreRender, Render, event handlers, etc, causing composite controls or repeater controls to produce gibberish. And then there is the misery of trying to integrate JavaScript into the machinery. I was just about to visit bookware and buy two fat ASP.NET MVC 4 books, obviously because I'm considering that as an alternative. I've read about the differences between the frameworks and I've run some tutorials and can see immediately that MVC takes you closer to the wire and gives you more control over rendering, with the penalty that you have to do more work. So I'm wondering if there is anyone here who has migrated to MVC 3/4 successfully and happily? Is it just substituting one huge complex framework for another huge complex one which simply changes the problems from one set to another? I worry about the number of files in a large MVC project. Are there tools or techniques to integrate scripting more easily? What about emitting html that is cross-browser safe or standards compliant? Will MVC make these things easier than in class ASP.NET? Should I give up on ASP.NET completely and use something like the GTK or the confusing family of similar tools to use html5? Can I leave the ASP.NET world totally
nTier ASP.NET MVC Application Architecture
Hi All.. Application architecture is an interesting and regularly debated topic among developers.. Everyone seems to have their own take on it based either purely on theory, real world experiences, and as always, a mixture of both. The application started out as a simple enough hosted ASP.NET MVC application where users would visit a website, register, log in, and work online.. Simple enough.. Recently there's been a change where the scope has creeped with an eye for the future, maximise code re-use, etc.. Fair enough.. Great concept.. My dilemma now is what's the best architecture for this app now that we will be (in the future -- when ever that gets here) accessing the system from mobile devices, and probably not through the default ASP.NET MVC interface that is currently being developed. I've been looking around for a decent online example of an nTier ASP.NETMVC application architecture, but most of the things I've found are all basically single tier where the author accesses the database via DAL directly from controllers. The app has morphed into the following Architecture... --- ASP.NET MVC --- | View |+ -- MVC Helpers || | Model || | Controller |+ -- Constants, Enums Helpers.. (Separate DLL) |+ -- Session Repository (in MVC Project) |+ -- Domain Types (Models ViewModels) (Separate DLL) --- --- --- --- --- \/ | WCF Service Call... /\ --- WCF Services SERVER --- | WCF Services || | Business Layer || | DAL |+ -- Domain Types (Models ViewModels) (Separate DLL) [.. this is the same dll as referenced by the Controller above] |+ -- Constants, Enums Helpers.. (Separate DLL) [.. this is the same dll as referenced by the Controller above] --- --- --- --- --- | --- DATABASE Server --- | Database --- --- --- --- --- This architecture seems to be working fine for now and I know that i'm probably going to have to change my WCF services to use a more RESTful approach, or implement another more mobile friendly interface, to make it easier for mobile connection, but that can happen down the track when i'm ready for that part. I'm also looking to use SQL CLR Types in the future so that I can be sure that the data in reference tables (like say PhoneType, PencilType, CarBrand, etc) mirror that exactly as in the Enums in the code. I've done some preliminary investigations into this and it is feasible, but whether it's worth it is another issue. How are people designing their ASP.NET MVC app architecture out there in the wild ?? I would love to hear/see your ideas/architecture.. Grant
Re: nTier ASP.NET MVC Application Architecture
The last time I wrote an MVC app which included an iPhone client, the architecture looked similar to yours. Although I would _never_ have a view model in the WCF project, since a View Model has everything to do with presentation, and nothing to do with data access. I always have a Mapper in the MVC project that maps all Models to View Models and vice-versa. I also consider a web-service really to be just another data repository, so I add a DAL in between the MVC Controller and WCF service. This means a controller is never tied to the web-service, so is independent of implementation. Now that MVC4 has the Web API available, I'd be tempted to abolish the WCF layer so controllers talk directly to the Business Layer. I would then just write Web API controllers that would service RESTful requests from a mobile client. This has the advantage of not having to share a DLL containing your Domain Types and enums. Regards, Nathan. On 20 March 2013 08:11, Grant Molloy graken...@gmail.com wrote: Hi All.. Application architecture is an interesting and regularly debated topic among developers.. Everyone seems to have their own take on it based either purely on theory, real world experiences, and as always, a mixture of both. The application started out as a simple enough hosted ASP.NET MVC application where users would visit a website, register, log in, and work online.. Simple enough.. Recently there's been a change where the scope has creeped with an eye for the future, maximise code re-use, etc.. Fair enough.. Great concept.. My dilemma now is what's the best architecture for this app now that we will be (in the future -- when ever that gets here) accessing the system from mobile devices, and probably not through the default ASP.NET MVC interface that is currently being developed. I've been looking around for a decent online example of an nTier ASP.NET MVC application architecture, but most of the things I've found are all basically single tier where the author accesses the database via DAL directly from controllers. The app has morphed into the following Architecture... --- ASP.NET MVC --- | View |+ -- MVC Helpers || | Model || | Controller |+ -- Constants, Enums Helpers.. (Separate DLL) |+ -- Session Repository (in MVC Project) |+ -- Domain Types (Models ViewModels) (Separate DLL) --- --- --- --- --- \/ | WCF Service Call... /\ --- WCF Services SERVER --- | WCF Services || | Business Layer || | DAL |+ -- Domain Types (Models ViewModels) (Separate DLL) [.. this is the same dll as referenced by the Controller above] |+ -- Constants, Enums Helpers.. (Separate DLL) [.. this is the same dll as referenced by the Controller above] --- --- --- --- --- | --- DATABASE Server --- | Database --- --- --- --- --- This architecture seems to be working fine for now and I know that i'm probably going to have to change my WCF services to use a more RESTful approach, or implement another more mobile friendly interface, to make it easier for mobile connection, but that can happen down the track when i'm ready for that part. I'm also looking to use SQL CLR Types in the future so that I can be sure that the data in reference tables (like say PhoneType, PencilType, CarBrand, etc) mirror that exactly as in the Enums in the code. I've done some preliminary investigations into this and it is feasible, but whether it's worth it is another issue. How are people designing their ASP.NET MVC app architecture out there in the wild ?? I would love to hear/see your ideas/architecture.. Grant
Re: nTier ASP.NET MVC Application Architecture
Thanks for comments and advice Nathan.. Your idea of DAL between WCF Service and MVC Controllers is a good one, and it does mimic how i have this set up currently (not explained properly previously - sorry).. I have my wcf services accessible only from within my SessionRepository objects. So the controller interacts only with the SR's and the SR talks to the WCF services. Comments on abolishing wcf layer seem sound, I was looking into the dual interfaces to the business layer (1 from mobile and 1 from mvc web). I haven't had the opportunity to explore Web API yet, but it looks like that opportunity has just presented itself.. fyi.. ViewModels packaged in same dll as models (for convenience).. not used in wcf services or as a DTO.. I agree with your _never_ sentiments.. thanks again.. Grant On Wed, Mar 20, 2013 at 11:35 AM, Nathan Schultz milish...@gmail.comwrote: The last time I wrote an MVC app which included an iPhone client, the architecture looked similar to yours. Although I would _never_ have a view model in the WCF project, since a View Model has everything to do with presentation, and nothing to do with data access. I always have a Mapper in the MVC project that maps all Models to View Models and vice-versa. I also consider a web-service really to be just another data repository, so I add a DAL in between the MVC Controller and WCF service. This means a controller is never tied to the web-service, so is independent of implementation. Now that MVC4 has the Web API available, I'd be tempted to abolish the WCF layer so controllers talk directly to the Business Layer. I would then just write Web API controllers that would service RESTful requests from a mobile client. This has the advantage of not having to share a DLL containing your Domain Types and enums. Regards, Nathan. On 20 March 2013 08:11, Grant Molloy graken...@gmail.com wrote: Hi All.. Application architecture is an interesting and regularly debated topic among developers.. Everyone seems to have their own take on it based either purely on theory, real world experiences, and as always, a mixture of both. The application started out as a simple enough hosted ASP.NET MVC application where users would visit a website, register, log in, and work online.. Simple enough.. Recently there's been a change where the scope has creeped with an eye for the future, maximise code re-use, etc.. Fair enough.. Great concept.. My dilemma now is what's the best architecture for this app now that we will be (in the future -- when ever that gets here) accessing the system from mobile devices, and probably not through the default ASP.NET MVC interface that is currently being developed. I've been looking around for a decent online example of an nTier ASP.NETMVC application architecture, but most of the things I've found are all basically single tier where the author accesses the database via DAL directly from controllers. The app has morphed into the following Architecture... --- ASP.NET MVC --- | View |+ -- MVC Helpers || | Model || | Controller |+ -- Constants, Enums Helpers.. (Separate DLL) |+ -- Session Repository (in MVC Project) |+ -- Domain Types (Models ViewModels) (Separate DLL) --- --- --- --- --- \/ | WCF Service Call... /\ --- WCF Services SERVER --- | WCF Services || | Business Layer || | DAL |+ -- Domain Types (Models ViewModels) (Separate DLL) [.. this is the same dll as referenced by the Controller above] |+ -- Constants, Enums Helpers.. (Separate DLL) [.. this is the same dll as referenced by the Controller above] --- --- --- --- --- | --- DATABASE Server --- | Database --- --- --- --- --- This architecture seems to be working fine for now and I know that i'm probably going to have to change my WCF services to use a more RESTful approach, or implement another more mobile friendly interface, to make it easier for mobile connection, but that can happen down the track when i'm ready for that part. I'm also looking to use SQL CLR Types in the future so that I can be sure that the data in reference tables (like say PhoneType, PencilType, CarBrand, etc) mirror that exactly as in the Enums in the code. I've done some preliminary investigations into this and it is feasible, but whether it's worth it is another issue. How are people designing their ASP.NET MVC app architecture out there in the wild ?? I would love to hear/see your ideas/architecture.. Grant