java - Should the interface define implementation specific enum values? -


consider following organization of classes:

interface restaurant  {     public void dine(object dish); }  class italianrestaurant implements restaurant {     public void dine(object dish)     {         // eat spoon , forks     } }  class chineserestaurant implements restaurant {     public void dine(object dish)     {         // eat chopsticks     } } 

since both restaurants serve different sets of dishes, correct way (design-wise) represent type of dish in interface?

will design decision define enum listing dishes -- italian , chinese -- part of interface, , use enum type dish?

you've used object type dish. meaning can considered dish here.

does mean can serve phone or pen dish? no; dish dish. why not create abstraction dish well?

better design :

interface restaurant  {     void dine(dish dish); } 

dish interface or abstract class; choose 1 more appropriate. every kind of dish served go separate class inherits/implements dish.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -