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

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -