tags:

views:

28

answers:

2

I want to extend an API (the Visio API - Microsoft.Office.Interop.Visio). The classes are not sealed. They have some weird COM stuff going on inside of them.

What are my options?

Specifically, what's the best way to seperate pure (external) api access from the biz logic of my app?

A: 

I would write an interface class.

Your interface class will be in C# which would be responsible for calling all the COM stuff.

Then in your other areas of the code (i.e. your business layer) you call your interface class for a document.

I would not expose the functions directly, even for example if Save() in your interface and the COM have the same signature. That would give your the freedom for future expandability.

David Basarab
A: 

You would use the Proxy or (probably more appropriate) Adapter patterns.

The basic idea is to create a wrapper class that contains an instance of the class you are wrapping. The wrapper class has methods appropriate to your usage that delegate to the wrapped class to do the actual work. This allows you to isolate your dependancy on the wrapped class to only the code in the wrapper class.

Eric Petroelje