views:

1364

answers:

11

I'm a pretty young developer, and still in the emulation phase of my career. I have read a lot about some topics like concurrency, and using unit of work to allow your business layer to control persistence transactions. I have even implemented some painful, but functional code that implements these topics. But I have not really ever seen a real world example of a truly elegant implementation. I don't have a lot of good TDD, pattern focused role models around me, so I'm forced to look at the outside world for guidance.

So, I'm looking for some stellar examples of open source enterprise app domain models. Preferably written in c#, but other languages would be fine as well as long as they are good examples of clean elegant domain model solutions.

Some of the things I would really like to see are elegant solutions for Concurrency, Business Rules and Object Validation, Transactions / Unit of Work, and semi transparent logging mechanisms. I'm also curious to see what some of the real world best practices are for exception handling in domain model code.

I know I could just start tearing into some open source projects at random, and try to decipher the good from the bad, but I was hoping the expert community here would have some good ideas of projects to look at to stream line the effort.

Thanks for your time.

Edit

I'm not really interested in frameworks that make design and construction easier. My choice of framework, or whether to use a framework is a necessary consideration, but is entirely separate from my question here. Unless those frameworks are themselves open source, and very good examples to dig through.

What I am looking for is a project that 'got it right', solving a real world problem with code that is flexible, and easily maintainable, so that I can see with my own eyes, and understand an example of how it should be done that is not a trivial 50 line tutorial example.

+2  A: 

While it's not exactly what you asked for, Juval Lowy of iDesign has coded up some wonderful WCF Samples that tackle many of the situations you mention above.

The book ".NET Domain-Driven Design with C#" by Tim McCarthy (Wrox Press) might also be of interest.

neontapir
Thanks, I have read Martin Fowler's Patterns of Enterprise Application Development, which has really set me on the right path. I'll have to check out Mr. McCarthy's offering.
Matthew Vines
+1  A: 

I'd take a look at CSLA and its sample application, ProjectTracker. Here at work I've done a few projects using CSLA and it really does help your BOs be much more powerful & useful.

While ProjectTracker is not a real-world domain model it does cover a lot of the situations that a real domain model would need to. So if you look at the features offered by BO layers utilizing CSLA you'll get a good idea of what good domain models should look like.

David Peters
We used CSLA in one of our major projects and we still call it the spawn of Satan. It, or at least our implementation, breaks the Open-Close principle. There are also a HUGE amount of issues with the implementation. Fortunately it was not my choice, and I will never use it again.
Bernhard Hofmann
I agree. It is the spawn of Satan. More accurately, it was an excellent pedagogical device that Rocky used to write a good book for OO beginners. Since it was pedagogical, it did not go far enough with refactoring and further needed design improvements (if it had gone that far, it would have lost its pedagogical value for beginners). Then, it was taken and pitched as a fully complete, ready-for-enterprise framework (which is ludicrous), and many business were duped into believing that pitch. Even developers were duped into it because of the religious fervor and guru-status behind it.
Charlie Flowers
+4  A: 

I liked lot the architecture of oxite cms at http://www.codeplex.com/oxite. I learned lot from that project. I use nhibernate for data access instead of linq2sql and it works good for me. Of course its not a large scale project but its a perfect start. CSLA does not follow the DDD paradigm.

The above book ".NET Domain-Driven Design with C#" by Tim McCarthy (Wrox Press)" is really good one.

The best book for understanding DDD is Domain-Driven Design: Tackling Complexity in the Heart of Software by Eric Evans. This book is the "bible" of good DDD design.

Beyond that many resources can be found on http://domaindrivendesign.org/. There you can find more videos and articles from DDD experts including Eric Evans and there is a sample application of good DDD design but unfortunately its in java :(

George Statis
Forgot to mention the free book at http://www.infoq.com/minibooks/domain-driven-design-quickly . It's a short version of Eric Evans book.
George Statis
After looking through Oxite, I think I agree with this article http://www.notsotrivial.net/blog/post/2009/01/07/Oxite-A-Deeper-Look.aspx
jayrdub
A: 

Have you considered reviwing the Castle Project?

From the Castle Project "Castle is an open source project for .net that aspires to simplify the development of enterprise and web applications. Offering a set of tools (working together or independently) and integration with others open source projects, Castle helps you get more done with less code and in less time."

Sebastian Gray
+1  A: 

You could check out nopCommerce i used it to try it work really nice and it has a good implemantation of DDD and BO, quite generic and fast, the install pattern is olso a classic so if you aiming a web apps you could check this out too.

Polo
A: 

I would take a look at the dofactory GoF site. They have a bunch of examples that you can purchase for a pretty small price including:
* MVC -- ASP.NET Web Application
* MVP -- Windows Forms Application
* MVVM -- WPF Appication
It also includes two very good books: "Enterprise Design Patterns" and "Head First Design Patterns"

SwDevMan81
I own and have read both of those books, and treasure both of them. Is the package really worth the money? What specific benefits did you get from it that you could not get from the bundled literature and its companion resources?
Matthew Vines
With out a doubt its worth it. You get the complete source code for aspt.net, windows form applications and UML models for each piece of the project. They are great building blocks for whatever you want to build with excellent use of design patterns.
SwDevMan81
+1  A: 

Rob Connery (of MVC Storefront and Weke Road blog) http://blog.wekeroad.com/ has been getting into DDD of late. The MVC Storefront app may be modified to reflect his learnings, or so I believe. Regardless, he has some good material on this topic.

The website http://www.domaindrivendesign.org has a C# sample app.

One thing about DDD; it tends to be tightly coupled (in the positive sense) with the bsuiness for which it is written. As a result, the best examples are probably tied up in IP and unlikely to be available as OS.

The kind of design I tend to see is usually the anaemic domain model.

objektivs
+1  A: 

I wish I could tell you that I had a great recommendation, since I would love to see this question answered with a consensus home-run choice. But as objektivs observed,

... the best examples are probably tied up in IP and unlikely to be available as OS.

However, there's one domain for which we have abundant open-source code: software development tools.

This is a cop-out (I haven't done the legwork either), but if this question fails to produce a solid choice and you want to pursue this yourself, I would recommend starting with some of the more mature tools that many of us already use: NUnit, DotNetNuke, ScrewTurnWiki, NAnt, etc.. They have several distinct advantages, not the least of which is that their domain models will already be (relatively) accessible to you.

Jeff Sternal
+3  A: 

Have a look at Martin Fowler's book, Analysis Patterns. It's an old book, so the class diagrams are not UML but something ancient (fortunately, the front and rear cover contains a description of the diagrams symbols).

And it doesn't have C# code. In fact it doesn't have any code at all because it is not a book about code, but a book about domain models. But it does have domain models to die for!

Pete
A: 

I recently come across tutorial on building Forum application with MVC, nHibernate, AutoMapper, and I find source code really good written and structured, with nice examples on using NH/FluentNH in web apps, domain model and repositories/services: http://mattias-jakobsson.net/Item/45/Building%20a%20forum%20application,%20Part%209

Hrvoje
A: 

I'm currently working on a project using StuctureMap, Fluent NHibernate, Asp.net MVC, AutoMapper, Castle, and xVal frameworks. I've been getting help from the sample projects Nerd Dinner and Code Camp Server. Please let me know if you have questions about any of these frameworks.

http://code.google.com/p/codecampserver/

http://nerddinner.codeplex.com/

shanabus