user137348
user137348

Reputation: 10332

Object oriented design question

I need to create a class which is building up an XML config file based on another objects.

There are 3 various objects. The building algorithm is very similar for all objects,but not same.

I was thinking of using a base class with an abstract method and then just create a derived classes with where I'd override the abstract method.

But the problem is those 3 object doesn't have a common interface or base class. Those objects are third party components. I can't refactor them. So there isn't any common contract for all objects.

Is there any convenient solution for this situation ? Maybe some design pattern I don't know about ?

Upvotes: 6

Views: 332

Answers (4)

WraithNath
WraithNath

Reputation: 18013

For simplicity you could also use a datatable class. These can read and write xml files.

http://msdn.microsoft.com/en-us/library/system.data.datatable.writexml.aspx

Upvotes: 0

abesto
abesto

Reputation: 2351

Facade seems to fit your situation.

Upvotes: 1

PaoloVictor
PaoloVictor

Reputation: 1306

You could define a XMLSerializable abstract class and then use the Adapter pattern to adapt these third party components into XMLSerializable objects

Upvotes: 3

Jigar Joshi
Jigar Joshi

Reputation: 240870

you can create your 3 custom class extending them respectively [I am not sure about C#], and implement a common contract.

Upvotes: 1

Related Questions