Ayende @ Rahien

It's a girl

Application review: Northwind Starter Kit

I continue to try to find a sample application for Northwind to use as my contrasting example for an article that I am writing, and I found the Northwind Starter Kit project. Even the project summary page gave me a few twitches, here is a small piece with the twitch inducing stuff bolded:

The application has been designed using common patterns, such as the ones defined within the "classic" "Designs Patterns" by Erich Gamma et al. and "Pattern of Enterprise Application Architecture", by Martin Fowler; though not required, these lectures are strongly recommended.

Guys! This is Northwind, the likelihood that you’ll need design patterns to build this application is nil to none! That just screens complexity overload.

Domain logic is implemented by means of a Domain Model, onto a layer of services adds application logic. The model is persisted by a DAL designed around the principles of the "Repository" patterns, which has been implemented in a LINQ-friendly way.

Northwind is a CRUD app, at its core, all of those things are adding complexity, and they aren’t really adding much at all. In fact, they are going to create just noise, and make working with things that much harder.

And then I opened the project, and I got this:

image

I mean, really? Seriously?!  22(!) projects to do a sample application using Northwind?

This is the point where I gave up on this as something that could be useful, but here are a few other gems as well:

image

image

I really like how the Update method does what it is meant to do, right?

Note that in either implementation, we are looking at totally and drastically different behavior.

Let us look at the interface, too:

image

The design is straight out of Patterns of Enterprise Application Architecture, and it is totally the wrong design to be using if you are using a modern OR/M.

Seriously, this is Northwind we are talking about, why make things so freaking complex?!

Tags:

Posted By: Ayende Rahien

Published at

Originally posted at

Comments

Diego Guidi
01/03/2012 10:20 AM by
Diego Guidi

22(!) projects to do a sample application using Northwind? I'm not sure that the purpose of NSK is to do a sample application, AFAIK looks more like a DDD framework (or, a part of) that uses Northwind data as sample data.

Diego Guidi
01/03/2012 10:20 AM by
Diego Guidi

22(!) projects to do a sample application using Northwind? I'm not sure that the purpose of NSK is to do a sample application, AFAIK looks more like a DDD framework (or, a part of) that uses Northwind data as sample data.

Roberto Messora
01/03/2012 10:22 AM by
Roberto Messora

simply, because you totally missed the scope of the project. that is, at the end, to explain architectural design patterns with a sample application. Northwind db is there only because this is the most known in the MS universe, it could be any other db. the project home page statement is very clear about that...

Diego Guidi
01/03/2012 10:22 AM by
Diego Guidi

sorry the doubled comment, please ayende feel free to delete the spammed content

James McKay
01/03/2012 12:24 PM by
James McKay

Design patterns for the sake of having design patterns. Yuk.

@Roberto: If Ayende misses the scope of this project, as you say he does, what do you think inexperienced architects will do? I'll tell you: they will cargo cult this bloated, cumbersome, over-engineered architecture into their own applications, even when it's not warranted, thinking it's a "best practice" even though they have no idea whatsoever what's "best" about it.

Certainly there is no reason whatsoever why you should have 22 projects in an application of this scope. You should have the minimum number of projects in your solution that you can get away with, otherwise you will end up with dependency management nightmares and compilation times measured in geologic eras.

Khalid Abuhakmeh
01/03/2012 12:39 PM by
Khalid Abuhakmeh

Kind of sad. Talk about scaring developers away from new technology. The best sample project created by Microsoft is probably Nerd Dinner. Not that Nerd Dinner is perfect, but it is a real site that can be used and had a purpose.

Honorable mention to Rob Conery's MvcStoreFront project.

tobi
01/03/2012 12:42 PM by
tobi

Man this is crap code.

raffaeu
01/03/2012 01:19 PM by
raffaeu

Ayende I am really surprised that you evaluate a solution based on its size or an architecture based on the number of layers. I grew up on NSK as it was my first layered application, almost 5 years ago and I personally believe that the effort Ugidotnet has put into this project during the years is simply amazing. The architecture reflect the most common architectural design patterns and represents almost the concepts expressed by Fowler and Evans. NSK is not a project to teach you how to work with Northwind and it is not a project designed exclusively for Nhb. It is designed to show how a layered application should be architected in .NET and there is also a book wrote around this project. I believe that your quick evaluation of this community project does not really represents what NSK is trying to accomplish.

Fish
01/03/2012 01:45 PM by
Fish

"...intended to be used as a blueprint when designing and implementing a .NET layered application architecture..." I think this clearly says, what this example is all about. I don't understand, how one could read it as "...this is how you should design und implement a Northwind application..." Sometimes, i really miss the point of reviews like this...

Diego Guidi
01/03/2012 01:51 PM by
Diego Guidi

Man this is crap code you've never seen the code you talk, right?

Mauro Servienti
01/03/2012 02:02 PM by
Mauro Servienti

1: I'm not involved at all in the project, nor I have any interest in it. 2: I do not think it's a fair review, since you are public person with a lot of given credit stating that something is bad could simply produce a disaster for that something even if it is not bad at all. Could simply produce comments like the tobi one ("Man this is crap code.") where I'm pretty sure that tobi has never seen the whole codebase. 3: Is like saying that the RavenDB project is crappy becuse in the solution there are 17 projects (that is not far away from 22), but we all know that to run RavenDB you do not need all the 17 projects, everyone can open the solution and understand at the first look that in the solution there are tests and different implementation for different technologies (Munin, Esent, Full fx client, Silverlight Client and so on). 4: Fish added one more good point. 5: Writing something like this "The design is straight out of Patterns of Enterprise Application Architecture, and it is totally the wrong design to be using if you are using a modern OR/M." is useless unless you tell us why.

Just my 2 cents. .m

Chris Staley
01/03/2012 02:06 PM by
Chris Staley

+1 for Roberto and Fish.

I appreciate what you're trying to do here, but this analysis is completely out of context with the point of the project.

njy
01/03/2012 02:18 PM by
njy

http://dl.dropbox.com/u/678683/greatest-shitstorm-of-our-time.jpg

Marta
01/03/2012 02:24 PM by
Marta

The story is simple...Ayende just doesn't like this code because he didn't write it

Brian
01/03/2012 02:33 PM by
Brian

Some day I hope you might look back on the tone of some of these of posts and perhaps feel a bit of guilt for the school yard bulley you turn into every so often. You've had an impressive career, especially considering how relatively young you are. It's disappointing to see this kind of immaturity when constructive criticism would earn you so much more respect. I will continue to follow your blog and I enjoy learning from you. Please consider learning something from this.

Apostol Apostolov
01/03/2012 02:43 PM by
Apostol Apostolov

@Roberto I don't think that explaining(as well as using) design patterns just for the sake of the design patterns is useful. Actually it's horrible. A design pattern is useful when there's a need of it, if it's used when there's no need of it it's simple overhead. So a better way of learning and teaching a design pattern is when you put it in a context which is appropriate for it. Much more value for the "student" that way.

@Fish A "blueprint" of an application should fit the business needs of the application. There's no point of using the same architecture or patterns for different projects with different needs. That follows the thought about - a design pattern should be used when it's needed.

That project would have had much bigger 'value' of it were using real world scenarios. The way it is now - it has very little to none value for learning design patterns. I think it will even confuse and mislead most of the people who will look up to it for learning as they probably won't know when to use the patterns that are implemented and use them as they are used in the project.

Mauro Servienti
01/03/2012 02:51 PM by
Mauro Servienti

to me "OnlineStore" (that is one of the projects and one of the top folders in the src) sounds like a real domain...and also stuff like IMarketingServices, ICatalogServices and if you take a look (as I did) at the HomeController you can immediatly see that is something real, that simply work and that simply solves that problem its own name states to solve: it's an online store.

.m

Felice Pollano
01/03/2012 02:52 PM by
Felice Pollano

For sure Ayende hit the point that an example with 22 projects is enrmous "per se" whatever is the scope.

Diego Guidi
01/03/2012 03:02 PM by
Diego Guidi

@felice if you download a nhibernate sample applications that contains also the entire source code of nhibernate, with all unit tests and so on, you can easily have a 22-projects solution, I think. Maybe not, but the point is that NSK is not a sample app, so what are we talking about? this is NOT a "sample application for Northwind"

Rafal
01/03/2012 03:12 PM by
Rafal

What's the problem with technology demo applications? All of them are crap or you are concentrating only on the bad ones?

Paul Davies
01/03/2012 03:30 PM by
Paul Davies

Design patterns, domain models, multiple layers, services, application logic, DALs, repositories... These are all concepts developers will need to understand if they are going to successfully develop even slightly complex applications.

One of the best ways to help developers understand these concepts is with sample applications. The initial sample applications developers should study should be simple stripped down ones, just to get them used to the concepts. It would not be productive to dazzle them with a full production quality mega application. We need all the concepts, but not too much functionality.

Therefore, some of these 'beginners' sample applications may not accurately reflect real world applications. Yes, they may utilise more concepts and paradigms than is needed for the functionality, but that is the nature of these applications - they're not supposed to be practical solutions!

As experienced developers, it becomes very difficult to place ourselves in the position of someone starting out, but everyone has to start somewhere.

plusplus
01/03/2012 03:54 PM by
plusplus

+1 for Ayende

Mauro
01/03/2012 04:04 PM by
Mauro

@Paul, I see your point. Nevertheless, Ayende's post carries a valuable message: I've seen too many software projects, especially in the "enterprise" world, horribly doomed by "architects" over-designing systems.

In my opinion, learning to avoid those bad practices is at least as important as learning design patterns.

Paul Davies
01/03/2012 04:30 PM by
Paul Davies

@Mauro, of course over-designing is a bad thing, and if an application like this was a real world project and put in to production then it would be a bad solution. But it is not, it is an application to demonstrate how to use design patterns. This seems to have been missed.

However, I must add that I think the Domain Model pattern does not add significant overhead to a project, and is always worth considering, even for very simple projects because you never know how complicated it will become in the future.

Mickaël
01/03/2012 05:40 PM by
Mickaël

+1 for Mauro I also would state that architect's main goal should be to remove useless complexity and useless code as much as possible

Dmitry
01/03/2012 05:50 PM by
Dmitry

The domain model looks pretty anemic to me. The repository abstraction does not add much value either.

The problem with such examples is they do not show WHY you would want to use those patterns.

Daniel Lang
01/03/2012 06:01 PM by
Daniel Lang

To all the critics above, I agree with you that it's not fair to judge the usage of patterns and the raw number of projects in this application, since the purpose if NSK is to demonstrate those.

BUT, there's no excuse for Select N+1, no excuse for wrong implementations of the Repository pattern, methods just return null or the unvalueable seperation between projects.

It's generally ok to have a repository patter, but then it should be implemented right, especially in demonstration app. It's also ok to have 22 projects, but the seperation should make sense and be valuable for the codebase.

Steve Sheldon
01/03/2012 06:06 PM by
Steve Sheldon

I'd have to spend more time looking at it, but I actually didn't think it was that bad as a starting point. It appears to be a project created by a group of developers who work at a consulting firm as a place to learn new technology ideas. This isn't some guidance out of Microsoft to which I'd hold a higher standard.

In fact this project appears to track along with the same lessons I encountered in the last year on a project I worked on, even seems to have hit some of the same stumbling blocks. So I can empathize.

Yes there are a number of things that I would do differently and that comes from trying something and learning from it.

Oren's tone isn't justified.

Tonio
01/03/2012 07:02 PM by
Tonio

I a gree with Daniel Lang

<there's no excuse for Select N+1, no excuse for wrong implementations of the Repository pattern, methods just return null or the unvalueable seperation between projects.

It's generally ok to have a repository patter, but then it should be implemented right, especially in demonstration app. It's also ok to have 22 projects, but the seperation should make sense and be valuable for the codebase.>

Andrew
01/03/2012 07:35 PM by
Andrew

NSK was developed to show the concepts expressed in this book. http://www.amazon.com/Microsoft%C2%AE-NET-Architecting-Applications-Pro-Developer/dp/073562609X Ayende, I am surprise that you would be so slating in your assessment of a project written by another respected author in the dot Net community. It's easy to forget that we as software developers are all somewhere on a learning curve. The book and the NSK project are a few years old now, but in my opinion together they do a good job in describing some of the concepts and ideas needed to put together a maintainable layered enterprise architecture.

Abdu
01/03/2012 08:43 PM by
Abdu

When I read posts like this, I start to wonder if the author produces just perfect code all the time.

Mauro Servienti
01/03/2012 09:48 PM by
Mauro Servienti

@Daniel Lang:

Just my curiosity: where is the Select N+1 and why the repository implementation is wrong?

.m

alwin
01/04/2012 02:02 AM by
alwin

Pardon my ignorance, but I can't think of a single online store that needs something as complicated as this?

Bob
01/04/2012 04:08 AM by
Bob

Wow. How many times are you guys gonna let Ayende troll you? What suckers.

throwspoop
01/04/2012 05:53 AM by
throwspoop

This review is a travesty, a sham, and a mockery...it's a travishamockery!

Raciel
01/04/2012 07:04 AM by
Raciel

@Ayende have you considered continuing with your Macto series as a Best Practices example? Count me in if you need volunteers; I see that as a more constructive way to illustrate the proper use of best practices. Thanks!

Valerio
01/04/2012 07:34 AM by
Valerio

I would like to know what's wrong in details too, especially about repository implementation, with ORM best practice (repository injection into domain model vs not), layered ddd architecture [dont look at 22 projects, the base ddd solution has 3 projects + UI (Domain, Repository implementation, application services) plus some infrastructure like InversionOfControl/Deploy. Off course you can put the first tree things in the same project and a sub folder, patterns are what matter :D

Ayende Rahien
01/04/2012 11:18 AM by
Ayende Rahien

Raciel, Yes, I want to make this go forward. Will probably do something about that in a few weeks.

Another Steve
01/04/2012 02:53 PM by
Another Steve

Ah, I see some of the Spaniards are back that were so angry about Ayende's DDDD Sample Project reviews from mid 2011.

The reality is, over complicating a simple problem to prove a point is never a good idea, especially in the .NET world where "cut and paste from MSDN" could be listed as a skill on most developer's resumes. Stuff like this only ends badly.

Alexandre Jobin
01/04/2012 04:13 PM by
Alexandre Jobin

I don't understand why you are bashing on this code project. Of course the project is overkill for the Northwind database but this is a starting point. For my projects, i have analysed a few open source code and i have taken the ideas that i liked from them: SharpArchitecture, NSK to name a few.

For those of you that say that NSK is crap, that the repository implementation is wrong, why don't you fork the code and propose a solution for that? It's very easy to bash on things but i didnt see anyone explaining the Why and the How to solve the problem or how to do it better.

I'm not a guru programmer so i can't argue with you guys on all the architecture stuff and good programming. This is why i'm really desapointed by this thread since that i didn't learn anything by reading you except that you are making fun on this guy very easily.

If you think that you are so good at coding frameworks, why can't we see any code and learn from you?

alex

oliver facup
01/04/2012 06:20 PM by
oliver facup

Totally agree with Alexandre. Lets see some real examples of what's wrong, with some why's and how's to solve them. you make me really scared to release code into the wild, why take the risk of getting shat on so you can all congratulate yourselves on being so clever. you don't see nearly so much bashing outside of the ms world

oliver facup
01/04/2012 06:21 PM by
oliver facup

Totally agree with Alexandre. Lets see some real examples of what's wrong, with some why's and how's to solve them. you make me really scared to release code into the wild, why take the risk of getting shat on so you can all congratulate yourselves on being so clever. you don't see nearly so much bashing outside of the ms world

oliver facup
01/04/2012 06:22 PM by
oliver facup

btw, your comments also suck. hope you get a good bashing over that too

Zsolt
01/05/2012 08:27 AM by
Zsolt

I don't really understand the reason behind these posts. In my opinion NSK is a sample and meant to show how to implement various design patterns using the MS stack. Creating samples is not an easy task. If You go for a complex problem (where the design patterns make more sense) the complexity might make the sample too difficult to understand. However if You go with simple stuff many patterns feel unnatural since those will look as an overkill for such simple problems. I do not want to say that NSK is perfect since no software is, but at least it gives people some ideas and they can decide on their own if these ideas match their requirements or not. If You have improvement ideas You could have used the time taken to write this post to contribute them instead.

Karep
01/05/2012 07:34 PM by
Karep

Another application same as all other apllications these days. Maybe you could look at https://github.com/Lokad/lokad-cqrs/tree/lean. This is something from guy that blogs here http://bliki.abdullin.com/ and here http://abdullin.com/about-me. He looks very clever to me but I don't know much about event sourcing.

Pavel
01/08/2012 02:25 PM by
Pavel

Yeah, it's very sad that people spend time writing these useless samples. It's possible to show proper usage of architecture patterns with Online Store project. First of all, prices of goods do change, so each item is represented by multiple rows in database, at least it's (id, date_effective) or up to three columns with dates. So you hide this price-changing logic in some wrapper to make basic searching easier. There goes repository etc.

Slamming repositories and units of work on top of ORM which already implements these patterns is stupid and shouldn't be teached. A person who can recite GoF book is not a good architect, the one who knows when to use patterns to make code better is.

Nazareno
01/10/2012 09:28 PM by
Nazareno

NSK is not an easy project. I start to “read” it some years ago and I found really difficult to understand it, but I never think that it was a problem of the project (or of its developers). My feeling was that I was not ready for it. Some years after I have the possibility (and the luck) to study better the underling architectures and I start to understand how to “use it”. At the moment this is not a sample app that you can reuse “ready, steady, go” on you projects. I use it to search suggestion about design or implementation, knowing that I have to write my own code to use it in my solution. It, also, try to investigate new topics (like CQRS) when there is no so much implementation reference project around. I think this is another good thing. Even if I do not think that you can measure a solution using the number of project, the large number of project is due to the fact that this solution tries to embrace the most common frameworks/tools. A real and complete implementation of a MES project (layered and with test project) made using lot of pattern inspired by this project count “only” 11 projects (obviously we have chosen only one ORM and one presentation design pattern).

Comments have been closed on this topic.