For example, we have next class.
class Request{
public:
RequestHeader header;
String body;
Request(const RequestHeader& header, const String& body);
Request(const String& json);
};
Some articles recommend split Request
entity and Request
build logic. For example, next.
struct Request{ //RequestDTO?
RequestHeader header;
String body;
};
class RequestBuilder{
public:
static Request build(const RequestHeader& header, const String& body);
static Request build(const String& json);
};
When we should use this recommendation? At first sight, it is useless complex. Constructor are normal part of a class. Why we should avoid this?
Aucun commentaire:
Enregistrer un commentaire