J.D. Meier's Blog

Software Engineering, Project Management, and Effectiveness

Sample Application for .NET 4.0 - Layered Architecture and DDD Patterns Sample Applications

Sample Application for .NET 4.0 - Layered Architecture and DDD Patterns Sample Applications

  • Comments 6

A code sample is worth a thousand words.  Here are a few projects to take a look at that go beyond just code snippets to show you how to put key technologies together in the form of sample applications.  (Note, if you are looking for just code snippets and focused code samples, you can check out the Microsoft All-in-One Code Framework project site on CodePlex.)

Layered Architecture Solution Guidance
Project Site - http://layerguidance.codeplex.com

”Designing and creating layered applications can be a challenging task to developers. Layered Architecture Solution Guidance is a Microsoft Visual Studio 2010 extension that provides a set of tools and guidance aimed at simplifying the development of layered applications.
Layered Architecture Solution Guidance is a
Guidance Automation Extension that integrates with Microsoft Visual Studio 2010 to allow developers to easily create and organize their projects in a layered fashion following the structure that is illustrated in the Layered Architecture Sample for .NET. It provides a set of solution templates integrated with a suite of code generators to make developing layered applications much simpler and quicker.

Microsoft Spain - Domain Oriented N-Layered .NET 4.0 Sample App
Project Site - http://microsoftnlayerapp.codeplex.com/

The main goal is to show how to use .NET 4.0 wave technologies implementing typical DDD patterns: N-Layered Architecture, Domain Entities, Aggregates, Repositories, Unit of Work, Domain Services, Application Services, DTOs, DTO-Adapters, etc.

Improvements in the Domain Layer

  • Using EF 4.1 POCO Code-First approach for Domain Entities/Aggregates/ValueObjects
  • Added more Domain logic within entities (no anemic domain)
  • Better exposure of Aggregates’ elements
  • Better support to navigations between Aggregates and elimination of inverse relationships not needed
  • Entity Validation support
  • Specification pattern implementation, use of expressions as specifications and composition support

Improvements in the Application Layer

  • DTO and DTO-Adapters support
  • Validation support
  • Improvements in exception management

Improvements in the Data-Persistence-Infrastructure Layer

  • Using EF 4.1, CodeFirst, DbContext
  • Persistence layer simplification and improvements
  • IoC/Unity: Elimination of abstractions no needed
  • Better testing strategy for Integration Tests

Improvements in the Presentation Layer

  • Reviewed and minor improvements in MVVM code.
  • In current V2.0 version we only support a Silverlight client. We'd like to add more clients in the future.

Improvements in the Distributed-Services Layer

  • Segregation in 2 Web-Services (One per MODULE).
  • Improvements regarding WCF exceptions handling (less spread code in Catch)
  • We currently use SOAP Web-Services, but we will switch to REST in the coming future when the new WCF Web API (WebApi.all) (still in beta) will support Silverlight.
  • Have you read Ayende Rahien's review of the sample code?

    If not you can find it here ayende.com/.../reviews

  • It looks like a review with good insights and debates.

    That's the beauty of any sample application, good or bad, there are always lessons to be learned (and I think there is often more benefit from the dialogues that surface, than the code itself.)

  • Sample code from MICROSOFT shouldn't be up for debate. Beginning developers or developers who are switching focus to another area look often to Microsoft for guidance. Microsoft has spent the last few years adovating best practices and design patterns, so it's a bit weird that those don't surface in the sample codes. The sample code is a great source to look how a certain feature (like EF) can be used, but using it as a guide how you should code is a big no-no.

    Why isn't sample code from Microsoft not reviewed by at least 3 people (like Hanselmann and Scott Guthrie) to make sure there aren't any surprises that can bring Microsoft (unintended) in discredit..

  • @ Dave -- Thank you for taking the time to explore this with me.

    The kettle did say up front it's not black, so to say it's not black, simply reinforces the point, ... or to argue that it should be black, seems like interesting rhetoric, so let's play that out.

    I'll share some quick thoughts ...

    > Beginning developers or developers who are switching focus to another area look often to Microsoft for guidance

    I can agree with you on this because it sounds like a reasonable assumption.  

    That said, "guidance" is a loose term, and I know many folks that explore features and make things compile "to make it work," long before they are worried about "making it right" for their scenario (and "right" depends on the specific context or scenario, anyway, and I'm not sure how you would find "canned code" for your specific scenario.)  

    ... And if they do care more about "making it right" up front, then they anchor and test it against their scenario, or, if they are depending on another supplier, then they look to the sources that focus on "best practice" or "proven practice" (such as sources like patterns & practices.)

    Personally, I usually don't play in the debates simply because, "All debates are wrong, some are useful."  Here's why:

    1. Often times, things are just simply taken out of context, which makes the arguments pointless and unfounded out of the gate

    2. Often times, things are generalized to useless or no longer relevant arguments (like the generalizations I'm making now to point this out.)

    3. Often times, it's the wrong intentions ... showing off, or playing the fame game.

    4. Often times, critics focus on minutia, or tangents, and lose perspective, instead of sharing solutions or useful suggestions

    5. Often times, there's a lack of scenarios or context to evaluate against, making the arguments casles in the sky or foundations in sand

    ... But, sometimes great debates happen.  Usually it's the process, and, if people are forced to challenge their assumptions, think a bit, re-enforce what they know, share what they know, or grow a little along the way, that's a good thing.

    At the end of the day, I find it's usually more useful for me to attempt to improve something and move it forward, than it is for me to pick it apart.

  • Since Ayende's series of reviews was mentioned, I thought it should also be pointed out that those reviews were about an earlier/old version of the sample code.

    It seems that most of the criticized points were addressed by the microsoft team (as you can read here: blogs.msdn.com/.../about-ayende-s-blog-posts-series-reviewing-the-nlayered-sample-app.aspx)

  • @ Martin -- Good link, and thank you.  It looks like a great outcome and bottom line:

    "We’ve been taken into account every of those posts as well as every comment from the community in his blog. Some comments to Ayende’s posts were also good points to think about.

    First of all, we are thankful to Ayende and anyone who provides feedback in order to improve our initiative ..."

Page 1 of 1 (6 items)