Object Oriented and COM+

  • Thread starter Thread starter Paulo Monteiro
  • Start date Start date
P

Paulo Monteiro

I have some doubts about object oriented development using
COM+.
To use COM+ my classes must inherits from
System.EnterpriseServices.ServicedComponent. With C# a
class can inherit only from one class. This means that I
can't have these classes:

public class Order
{
public virtual void Create()
{
// insert a record in orders table
}
}

public class SpecialOrder : Order
{
public void Create()
{
// create a order
base.Create();

// Process the special order by example
// approve the order. Insert another table.
this.Approve();
}
}

Any suggestions?
I think in use ADO.Net transactions but with this solution
I don't need COM+ for anything.

Thanks in advanced,

Paulo Monteiro
 
Sure you can, if you want. Just make Order inherit from ServicedComponent,
and then SpecialOrder when it inherits from Order will also inherit its
superclass ServicedComponent.

You can use ADO.Net's transactions if you like, without getting
ServicedComponent and COM+ involved, but going the COM+ route is good for
scalability if you think your application will require it. COM+ is also good
for distributed transactions. Connection pooling comes for free with COM+,
without any code on your part whatsoever, and is good for scalability in
applications that open and close connections frequently.

As an aside, recommended design patterns for database-oriented applications
these days discourage placing database operations in business-logic objects
(your Order object). In the recommended architectures, database access
occurs in a specialized data access component between the business-logic
objects and the database. Those objects would inherit from
ServicedComponent, and the mid-tier (Order, SpecialOrder) objects would not.
Microsoft has a lot of white papers on their site that discuss these aspects
of software architecture. As a start, try searching for "DALC" (Data Access
Layer Component) on www.microsoft.com and see where that leads you.

Best regards,
Tom Dacon
Dacon Software Consulting
 
Back
Top