Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,128 | Comments: 45,551

filter by tags archive

Code reviewThe PetShop Application

time to read 2 min | 316 words

I gave a talk about ReSharper today, and I used the PetShop demo app as the base code. I have purposefully avoided looking at the source code of the sample until today, because I wanted to get a gueniue experience, rather than a rehearsed one. I don't think it went as well as it could have, but that is not the point of this post. The point is to talk about just the code quality of the PetShop application.

First, let us see what the PetShop application is:

The Microsoft .NET Pet Shop 2.0 illustrates basic and advanced coding concepts within an overall architectural framework

The Pet Shop example is supposed to illustrate "coding concepts", but mostly it demonstrate those that you want to avoid. I was shocked by what I was seeing there.

I am going to touch just the account class, because if has enough issues all on its own. The account class is supposed to be a domain entity, but what do you see when you open it?


And I really don't like to see SQL inside my code.

And then there is this:


And suddenly I am confused, because I see a class that is doing the work of three classes, and that is just by casual browsing.

And then we had this:


Somehow, public fields and violating the .NET naming conventions doesn't really strikes me as a good idea.

Code duplication, like between the Account.Insert() and Account.Update(), both have significant duplication in the form of:


I thought that the whole idea of a sample app was to show of best practices, and that is... quite not so, in this case.

More posts in "Code review" series:

  1. (31 Dec 2015) The concurrent dictionary refactoring–answer
  2. (30 Dec 2015) The concurrent dictionary refactoring



Yeah, this is an oldie but a goodie. I remember reading about this a number of years ago.

The originally translated paper seems to be missing, but here are links to the original in French and the Google translation (which seems remarkably good) of something written in 2002.



Interesting - I found the original English translation here:



Would be interesting to know what FxCOP thinks of it ...


What would be a good example of an application to learn from if I wanted to learn better coding techniques?


recorded videl of your talk will be available?


recorded video of your talk will be available?


Shouldn't you have been reviewing Petshop 3.0, though?

From http://msdn2.microsoft.com/en-US/library/ms954623.aspx: "Version 3.x of the .NET Pet Shop addresses the valuable feedback given by reviewers of the .NET Pet Shop 2.0 and was created to ensure that the application is aligned with the architecture guideline documents being produced by the Microsoft."


PetShop 2.0 is in deed a little out of date. Could have used the Global Bank sample packaged with WCSF / WCAB as this is essentially what P&P are touting as best practices right now. Alternatively, DinnerNow.NET would have also been an up to date example.

John Chapman

Was the point of the .NET Pet Shop really to show a good architecture? I always thought it was about showing how .NET is faster than Java. Wasn't the Pet Shop originally a Java demo after all? I thought the goal was to put together charts that showed the .NET bar far beyond the Java bar, and as such the architecture was second fiddle to performance numbers.

As far as sample architectures go, I thought that was the initial role of IBuySpy.

Ayende Rahien

Arild & Ko,

Because PetShop 2 was the result that I found when I searched for it.

Ayende Rahien

John Chapman,

No, that was PetShop 1.0, where MS was accused of cheating, and they re-wrote it to make it match the Java impl better.

Ayende Rahien


Cuyahoga is a good application with good architecture.

Comment preview

Comments have been closed on this topic.


  1. The worker pattern - 8 hours from now

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats