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
} ;
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.
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.
No, in current form this doesn't look like any design pattern, but
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.