Kadir Erdem Demir
Kadir Erdem Demir

Reputation: 3605

Which design pattern a composed object just for proxy purposes relates?

I have my object D which encapsulates different structs(A,B,C in this example). D is mostly for being passed as an parameter to an object called "RealClientInterface". Because D composed of A,B,C which "RealClientInterface" needs to run its functions.

My question if D relates to a design pattern? If it does which design pattern(s) D relates in this case?

Is it a composer since it is being composed of A,B,C? Or it is proxy or builder? Since it is there just as an proxy the real read/write is being done by RealClientInterface?

I need this information for giving a good name to my class D and also documentation purposes.

struct A
{
    //Some data
};

struct B 
{
    //Some data
};

struct C 
{
    //Some data
};

struct D 
{
   A a;
   B b; 
   C c;
};

struct RealClientInterface
{
    void foo ( D& d )
    {
        //reads d.a and inserts d.b
    }

    void foo2 ( D& d )
    {
        //reads d.c and inserts d.b and d.c
    }

    // Many other functions
} ; 

Upvotes: 0

Views: 59

Answers (3)

Krzysztof Błażełek
Krzysztof Błażełek

Reputation: 893

No, in current form this doesn't look like any design pattern, but

  • If D would control access to A, B, C => Proxy Pattern
  • If D would simplify interface of A, B, C => Facade Pattern

Upvotes: 0

stefaanv
stefaanv

Reputation: 14392

A class containing other classes for whatever reason is not a familiar design pattern, it is just a composition, which is a concept meaning a class containing other classes. The class could also contains references to other classes (aggregation) or it could inherit. You can find more information on composition here.

You can find an overview of common design patterns on Wikipedia, but I don't think this is in there.

Upvotes: 1

Sheila de Pope
Sheila de Pope

Reputation: 103

No, D doesn't relate to any of design patterns. In your case D is just a container for objects a, b and c of type A, B and C respectively. 'Container' would be a suitable name to use in your documentation.

Upvotes: 0

Related Questions