I have two classes. Let's call them PostClass and CommentClass. Both classes implement the Reportable interface:
public interface Reportable {
void report();
boolean isReported();
. . .
Now I need to add two additional methods to each one of the classes. These methods logically fit into the same interface but needs to have different names. For example:
PostClass will have methods -> remove(), restore()
CommentClass will have methods -> hide(), show()
Question: What would be the preferred way to design this change? The options are as I see it:
- Create an additional interface which will extend the
Reportableinterface. Problem: Too many interfaces - Add all four new methods into the
Reportableinterface and then just leave the irrelevant two methods unimplemented in each class. Problem: Untidy/ugly
Aucun commentaire:
Enregistrer un commentaire