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,026 | Comments: 44,842

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. (15 Apr 2011) Who Can Help Me
  2. (01 Apr 2011) SharpArchitecture.MultiTenant
  3. (28 Nov 2007) PetShop 3.0
  4. (28 Nov 2007) The PetShop Application



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.


No future posts left, oh my!


  1. Technical observations from my wife (3):
    13 Nov 2015 - Production issues
  2. Production postmortem (13):
    13 Nov 2015 - The case of the “it is slow on that machine (only)”
  3. Speaking (5):
    09 Nov 2015 - Community talk in Kiev, Ukraine–What does it take to be a good developer
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats