Question

Quite frequently, I use an Adapter-like design to expose different aspects of data objects.

For example, in a 3D modelling application I use an object hierarchy to represent the 3d models in the scene. This hierarchy contains lots of internal information and is quite complex to traverse.

For exporting the 3D model data to different file formats (which involves quite significant transformation and omitting or converting some objects), I have a separate class called ModelAdapter. It extracts the important information of a 3D model and provides them in a different format, usable for export. The export plugins, in turn, read the data from the ModelAdapters and have nothing to do with the internal scene data structure.

For Example:

class 3DModelAdapter
{
private 3DModel internal_model;
public List GetTriangles()
{
 internal_model.Do_Some_Complex_Thing_To_Retrieve_The_Triangles();
}
...
}

Is this a valid use of the Adapter pattern? Is there a better way to accomplish the same thing?

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top