Preferred Software Architectures and Standards – Part 1
So I figure a great place to start out the real meat of my new code blog would be what is my current favorite design methodology for an N-Tier web application and some of the best practices to adhere to when starting out. First I would like to start out by saying a firm foundation of any application is paramount to the future success of that application. You will often talk to developers, myself included, who skimped on up front design and paid for it for the duration of the project. This is critical on any project because even a small quick hit can often turn into a huge monster with scope creep and sufficient lack of foresight.
So lets kick this off with technologies for part 1 shall we?
Presentation Layer - This is what serves your web pages. At the time of writing this MVC3 is king with a looming heir to the throne on the horizon being MVC4. All the same great features we have come to know and love about MVC3 with a few new ones surrounding device targeting, improved Inversion of Control support, scaffolding, HTML5 native support, and more. We augment this with the latest version of JQuery, JQuery UI, JQuery validate, Modernizer, and depending on need Knockout (Which might I add these all come pre-loaded in your scripts folder but all too annoyingly are frequently many versions out of date.) Resource to get you started: http://www.asp.net/mvc
Service Layer – This is where the guts of your application lives and is comprised of 3 main segments itself. Which if you are talking about N-Tier application development this solution file will house the final 2 tiers in a 3 tier architecture.
-
Service Endpoints – WCF hands down wins for exposing your functionality across the wire. This should be kept simple and clean and will interact with your domain project, persistence through an interface defined in your domain project, and handle the translation between data bound entities and your Data Transfer Objects (further referred to as DTOs) using a nice little utility called AutoMapper. Some resources on this:
-
WCF Primer: http://msdn.microsoft.com/en-us/netframework/dd939784
-
AutoMapper: https://github.com/AutoMapper/AutoMapper/wiki
-
Business Logic – We will call this your “Domain” model, which anyone familiar with DDD is already smiling. This is where ALL of your business logic lives and the interfaces that define the external concerns like persistence and auxiliary dependencies (for example: an external service reference to say Melissa Data for address validation) lives.
-
Domain Driven Design: http://domaindrivendesign.org/resources/what_is_ddd
-
Persistence Layer – EF 4.3 is the current version of Entity Framework out and hands down the POCO or Code First model for EF is amazing. I would suggest digging into Fluent configuration over annotations due to the agility that can be gained using fluent EF configuration.
-
EF POCO (Code First): http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
Disk Storage – This is the final main piece of the “application”. This is your actual write to disk means of storage. Using .NET you really only have one viable choice which is SQL Server. SQL Server 2008 is a must as it comes loaded with code completion and as a developer this will save you a ton of time. For anyone using 2005 or lower I strongly encourage you to at least grab the developer bundle from Red Gate which gives you some of the nicer, in my opinion, features of 2008.
I know this is a bit entry level for most but I’m going to try to start out simple and work up to more complex scenarios and concepts. My hope is for a entry level developer with isolated understanding of software design will be able to read this and grow in skill as the posts progress.
This concludes Part 1 of Preferred Software Architecture and Standards. Next up we will dive into building out an MVC application, Service Adapters, and the importance of creating view models for projecting the DTOs into. I don’t have all the parts planned out yet so please bear with me. This will likely end up being a fairly daunting series that covers a lot of ground. Check back often or subscribe, shooting for at least 3 posts a week to start and see where we can go from there!