java - How do you deal when the implementation for an interface method is the same for some classes? -


Assume that I have defined the interface ISOE interface with foo and bar methods.
e.g. Public Interface ISOM Interface {Public Weed FU (); Public zero times (); }

Assuming that I have class A and B., for them it is understandable to implement the interface. But this also does not make sense for a different implementation for foo () .
Achieve A or B from A to be Wired / Strange, is there a standard coding practice?
I think I can make some utility classes to implement foo () and call it as a representative, but I was wondering if this Structure can be handled differently

Update:
I stumbled upon this to give my full understanding of the question: And I was trying to understand this Is this facility less than conventional OO concepts because we have them in Java Whether you use it or not

Your edit suggests that your real question is: "What is the Pearl in Java Is roles equal? ​​"

Because Java 8 introduced the default methods in the interface, the interface looks like a very good equivalent for interface roles, especially with , What you want in your example, can: foo () :

  interface isoiniffe Your default implication is here (public default) (foo) * /} public zero times (); // abstract should be implemented by subclasses, class one tool must apply ISomeInterface {// only, can reuse the default effect of foo} uses class B to execute only the bar on the ISM interface {//} Should use the default import of foo again)   

If there is any feature about roles then please remember me please tell me otherwise, I think Java 8 interface Is a good surrogate for the roles.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -