java - Which class should do the work? -
i building sales system dissertation , keep debating myself in design, class should doing work?
so these 3 classes;
facility class - class central class coordinator between others , gui
product class - represents details of product
sales class - represents sale of multiple items
when comes selling products, big question is:
"which class should calculate total price". facility class or sales class?
whats best practice?
thanks in advance
my first impulse order these classes responsibility regarding model-view-controller design (because mention gui , interfacing class it).
facility
- according statement controller, connects gui (view) data (models).product
- model class, since holds data , business logic.sale
- class connected multipleproducts
, multipleproducts
share samesale
, because product can sold more once (this assumption) , sale can include multiple products. model class.
since sale
class represents multiple products , interested in (e.g.) sum of individual prices of these products, place store method.
Comments
Post a Comment