samedi 11 septembre 2021

Head First Design Pattern: When to not use Interface (specifically in Java 'interface')

I have just started reading the book, and in the Strategy pattern they discouraged the use of interface to enforce an implementation of a method.

However, upon the next chapter: Observer Pattern, they did just that. Wherein, they used a Display interface with a display method to be implemented by the concrete observers.

My question is: in the end is it really okay to use interfaces like that? If not, is there a better method on how to do this?

Aucun commentaire:

Enregistrer un commentaire