Refactoring With Com Plus Technologies

[From RefactoringWithaFrameworkExperiences]

Based on the book, "Designing Solutions With COM+ Technologies" (DesigningSolutionsWithComPlusTechnologies).

This page includes JeffGrigg's experiences writing and refactoring code that uses the book's framework. The main motivation for writing this is to help MartinLippert with his PhD thesis.


The book has good examples and advice on how to effectively use MicroSoft COM/DCOM/COM+ technologies, including object persistence mechanisms and strategies for managing network round trips on calls to DCOM objects.

Of particular interest to me is what I'll call the "Object Persistence Framework." It's documented in chapter 11, as the "Four-Tier Enterprise Application Architecture." (I would call it 2-tier.)

The framework enables using XML documents as "streams" to...

  1. carry business data from MTS server objects to clients,
  2. build hierarchies of COM business object proxies, for client use, and
  3. uses a similar XML document "stream" to save changes to the database (and to return database-assigned values, such as system assigned keys, to the client business proxies).


The book describes the framework in over 80 pages, not counting whole chapters devoted to supporting concepts.

Briefly, this is how you'd select an Order, given that you know the primary key "order_id":

How the framework persists changes back to the database:



[JeffGrigg says...]

While writing client code that uses this framework, I encounter opportunities for refactoring:

The data layer code is responsible for mapping between the framework's XML streams and the database. The framework's XML streams (each an XML document), each contain a hierarchy of business object instances, each with named attributes/properties. Relational databases contain (typically) normalized tables, which can only be accessed and manipulated using SQL.

"Out of the box," the book's examples already demonstrate the following good practices:

But there's still a lot of repetitive coding -- all those INSERT, UPDATE, DELETE and SELECT statements, WHERE clauses, refetching system (database) assigned column values, and lots of manipulation of column/property data.

[This is where the REFACTORING starts.]

So, starting with a few data layer classes I wrote during the first iteration, I refactored and generalized out a set of data-driven functions to form the "Data Layer Implementation Library." You can delegate work to it, from your Data Layer classes, to perform these functions:

-- JeffGrigg


CategoryComponentObjectModel


EditText of this page (last edited February 16, 2004) or FindPage with title or text search