Trying to see better design for the following. Not familiar with design patterns but trying to see if any design pattern or otherwise will make better solution.
Consider
Class A {
String field1;
String field2;
CA ca;
}
Class B {
String bfield1;
String field2;
Common cb;
}
Class C {
String cfield1;
String cfield2;
Common cc;
additional fields etc..
}
Do some process and based on some criteria
Create - Populate Object C from fields from A; NotActive - Populate Object C from fields of B but need to apply rules to cb before mapping to cc; Update - Compare fields from A and B and also apply rules to ca and cb then populate Object C.
One way is to use visitor pattern for create, notactive,update that returns the mapped Class C object. The other way of looking is since class B is more similar to Class C, for non active and update use similar process for mapping. I think I need to address a) Which design will help in mapping between classes without rewriting the code in several places. b) Where to apply rules for the ca,cb and cc. Do I give the responsibility to Class A, Class B and Class C
Appreciate any help.
Aucun commentaire:
Enregistrer un commentaire