c++ - Design pattern suggestion for storing the client information in map in server application -
my application server, , client give request processing. client contact me(server) multiple times handling same request .
map<clientid,clientinformation>
usually, i'll store information received client in stl map processing client request next time.
once client satisfied in servings, clear entry in map respective client id.
this sample clientinformation
class:
class clientinformation { int notrequiredfornexttime; // information not required processing client request next time int requiredfornexttime; // information required processing client request next time int requiredfornexttime; // information required processing client request next time int notrequiredfornexttime; // information not required processing client request next time int notrequiredfornexttime; // information not required processing client request next time userdefinedclass class1; }; class userdefinedclass { int requiredfornexttime; int notrequiredfornexttime; }
in above class, require requiredfornexttime
stored in map. other information required @ time of processing current request.
clientinformation
class can have user-defined class member(userdefinedclass
), , of userdefinedclass
members not required next time.
is there design pattern, provided optimized solution(memory usage) problem?
in case, separate required- notrequired- fields, in separate classes. could...
have notrequired- class held pointer in required class, such
delete
it, orhave required- class held pointer in notrequired- class, such move out distinct container, or
keep them in separate containers right start, or
write code construct required class clientinformation class - copying required fields (copying inefficient, might require less change existing code, if have any).
- "serialisation" 1 form of this, albeit in data's not kept in accessible structure during storage, , distinct deserialisation step needed recreate required class, or perhaps repopulate required fields of clientinformation object
(i'm not aware of relevant design pattern names, not programmer needs validated design pattern name - developing mental awareness of data modelling options means can apply "common sense", named or anonymous.)
Comments
Post a Comment