# Wednesday, 23 January 2008

Commerce-Server-2007-Logo A while back a friend of mine posted a comment here asking me to describe what it's like developing with Commerce Server 2007. Initially I wanted to reply to him in comments but thinking more on it I really want to provide a different and real perspective on how Commerce Server is to work with as a product, a perspective in which I want to dig a deeper than the usual how-to and tutorials you see on the various Commerce Server blogs; mine included.

Check out part 1 Secure By Default where I discuss the security aspects of Commerce Server, part 2 Three-way Data Access in which I write about the various ways of getting data into your applications, part 3 Testability which not surprisingly is all about how CS lends itself to unit testing, part 4 Magic Strings Galore where I take on low level aspects of the APIs, part 5 Pipelines where COM makes a guest appearance in our mini series, and part 6 which is all about getting your solution into production.

The Starter Site

Ah the fabled Starter Site... When I look at my search logs for this blog I see that people are very interested in the Starter Site and are doing lots of searches for it. Ever since Commerce Server 2000 Microsoft has provided a reference implementation of a commerce site for developers to learn from. Ever since Commerce Server 2000 it's been and all-around bad idea to actually use the Starter Site in production. As a Commerce Server developer you'll cross paths with these guys so it's important for you to know what they're al about.

So is it still a bad idea to put the reference implementation for Commerce Server 2007 in production?Yes and no, while the Starter Site is a step up from previous reference implementations it's still not what I'd call production ready. The Starter Site provides great insights into the workings of the Commerce Server APIs but it's not exactly a shining example of web application architecture.

The Starter Site is done as a web site project in Visual Studio which by itself is not an issue. The problem though is that there is no separation between UI and application logic. All business logic is placed in the App_Code folder of the web site which means that it lacks reusability completely.

Additionally the code which is there lacks support for testing as well, all components are implemented directly on top of the CS APIs which as I discussed in part 3 Testability means that we have no means of creating unit tests for our custom code. Not only that but the entry point to the subsystems used is the CommerceContext which is initialized by a number of HTTP handlers during execution of the ASP.NET pipeline, this means that we're effectively bound to an ASP.NET context which in turns blocks the ability to test anything.

Now the abstraction provided for the Profile System does show some good ideas. Profiles are abstracted in nice type safe objects which in turn are mapped to the underlying Profile System by use of attributes. Great idea but I'd like to have seen the idea carried a few steps further. For instance relationships are implemented by a pattern that the developer needs to redo for every single property which reference another profile or list of profiles.

Oh and some corners are cut here and there: We have a nice abstract BaseProfile class which serves as the base for all profile implementations, perfect but in an especially grievous example a method in the BaseProfile is implemented with knowledge about one of its inheritors, see that's bad OO design right there.

Finally the Profiles which is most Commerce Server projects serve as the data store for domain objects are bound to ASP.NET like the rest of the business logic of the Starter Site meaning you can't reuse them in other contexts like winform apps.

All that said the Starter Site is a very nice running reference from which you can learn a great deal. There's no code like running code, all else aside the Starter Site is probably the best reference and source of learning Commerce Server especially if you're already familiar with earlier versions of Commerce Server.

Provided with the code base is the control gallery which is a collection of ASP.NET controls that you can use in your own site. They're implemented as server controls which means that they're easily transferred to other sites. That's ten points right there :)

So while the Starter Site is an exercise in bad web application architecture there are very good reasons for downloading it and taking a look at it. Learning is the obvious route but if you find yourself tight for time or money on your particular e-commerce project you can get some good results with the Starter Site as a foundation provided you take care and identify the weaknesses of the code base and rearchitect accordingly.

Comments are closed.