oop - Choice of inheritance from class or declaring fields -
say have class product {string name; double price;...}
so if want implement seasonal or discounted product, can add declare ispromoted/isseasonal or can create new class promotedproduct : product {...}, seasonalproduct : product{} , more.
i have been told beginners tend misuse inheritance , how evil. not sure if considered misusing in case. or maybe both wrong , using interface better etc.
will products on promotion or not - ie - no actual promotion details (different rates, dates etc) - if you'll want first solution. otherwise you'll want relation promotions class store such details.
hope helps.
note: general programming answer having never used java personally.
Comments
Post a Comment