I'm a new in oop. I don't know if the question is correct. I mean, in other word, the object requires all-time implement.
following is my cace:
I want to design a program which has a simple logic: DEVICE execute a command from upper level.
- DEVICE consist of some elements.
- a command(or task) comes from upper level or DEVICE itself.
- difference between two DEVICEs is just different strategy to manage those elements.
I know the S.O.L.I.D principle. but how it work in practice?
thus, I think that the strategy pattern is match this case.
with this thought, I create two objects:
/* DEVICE */
class Device{
private:
strategy operate;
public:
/* ... */
};
/* server */
class Server{
Task task;
private:
/* ... */
public:
/* ... */
};
but, both of two objects will generate task. so, it will always refer itself to each other. moreover, there is a big restriction when put them into different threads or processes.
does my thought correct?
is there a better way to deal with this case?
how to design a object may contain thread or loop(infinite)? how to degign/deal with objects may have reference?
Aucun commentaire:
Enregistrer un commentaire