user408141
user408141

Reputation:

The most elegant way to write an abstraction layer

I'm curious how to write an abstraction layer. By abstraction layer, I mean a wrapper above one or more 3rd party libraries.

Or do I have to solve it like this?

#include<an3rdpartyl>
#include<another3rdpartyl>

class layer
{
private:
    an3rdpartyl* object1;
    another3rdpartyl* object2;
public:
    //...
    int loadModel(char* file)
    {
        return object2->LoadMeshFromFile(file);
    }
    //...
};

Upvotes: 1

Views: 1728

Answers (2)

Emile Cormier
Emile Cormier

Reputation: 29209

Take a look at the Facade, Adapter, and Bridge patterns. Or even better, just pick up the "Gang of Four" Design Patterns book and learn about software design in a whole new light.

Upvotes: 1

JRL
JRL

Reputation: 78003

You might want to look up the Decorator pattern.

Upvotes: 1

Related Questions