The source code for SmartPetShop, my sample project for Composite UI Application Block, is now available for download.
If you want to run it, first I recommend to download and install the original PetShop.NET 3.2 from Microsoft , as it will setup properly the database and register COM+ services. After that you should update the connection strings in Win application's app.config with encrypted settings taken from original Web PetShop's web.config. Simply find settings like and copy them to app.config. Later I will try to provide my own installation scripts for this. Finally, to compile the code you would need to place CAB DLL's om the Lib folder.
Currently my changes concentrate only on presentation layer so I simply replaced the Web project with my own Win project. All other code remains unchanged (with kind of proves that this is indeed well architected application).
Future plans
My first goal was to create sample application that would demonstrate how CAB can be used in real-life project. But during the process I realized I can further extend this sample and try to apply some other new technologies emerging in .NET world. So here are my future plans for this project.
- Finish conversion to Windows Forms
From the original Web PetShop there is only couple of functions left to implement (for placing orders). But looking at CAB I already covered following features:
To make it complete I still need to discuss:
- Reimplement Data Access Layer using Enterprise Library
CAB is only a little brother of EntLib so I think it makes sense to show how to use them both in the same application. I'm also curious to what degree it will simplify the original code for the data access and business logic layers. I will definitely explore the Data Access AppBlock but I will also try include others like Logging, Exception Handling and Caching. Also, I should try to replace the PetShop's ConfigTool with EntLib's Configuration. At the same time I would try to deploy the database on MS SQL 2005 Express using user instance databases and embedded update scripts (seen nice articles on both recently).
- Separate client code from server
I called my version SmartPetShop to indicate that it will support the SmartClient architecture. There are three main characteristics of SmartClients: rich user experience, intelligent updates, and offline capabilities. If we assume that my CAB implementation provides richer experience that the previous Web based (actually it tries to mimic it closely) there are two things left to address. For installation and updates I would use ClickOnce, but there is not much to say that wasn't well known already. So last thing is to enable the application to work without connection to server. In this mode it should at least enable to browse the product catalog and place items in shopping cart. Then, when application goes on-line, user can submit orders and check status of earlier orders.
Currently the application connects directly to database so the main task here would be to move the data access and business logic to separate server process. Necessity to connect these two will allow me to explore another exciting new technology, the Windows Communication Foundation (aka Indigo). This will also test the current architecture as it seems that it should suffice to switch ServiceAgent implementations and there should be no change to UI logic.
- Another type of client
When I'm done with above I should have working example of SmartClient. Then I can try to implement another type of clients. There are two candidates. I'm really excited to start working with Windows Presentation Foundation (aka Avalon), however I don't think I would have opportunity to apply it in my professional work in foreseeable future. It is more likely that I would need to refresh my skills in ASP.NET. I stopped working on Web apps almost one and a half years ago and didn't had opportunity to try out all the goodies in ASP.NET 2.0. I'm also excited about the Atlas extensions since I've done some work with AJAX technologies on my own (some really cool DHTML behaviors).
So here you have it. I will try to do as much as I can of this in upcoming months. I need to learn these things anyway but if I also put myself to write about it the process is more systematic. Feel free to drop me a note if you have additional ideas or like me to explore any particular topic more closely.
Update: I just discovered that last week Microsoft released .NET Pet Shop 4.0. What a perfect timing! I guess I need to revise my goals as some became obsolete. Most notably these guys saved me work (and pleasure) of upgrading to ASP.NET 2.0. I haven't reviewed the code yet but judging from the accompyning article most changes were made to the presentation layer (bummer!). However, it seems it would be easier to update my code base now before starting any modifications to other layers. Anyway, it's great this project is not dead and I'm sure it will be valuable source of information on building enterprise .NET 2.0 applications for everyone.