dimanche 11 juillet 2021

does default interface violate the Interface Segregation Principle?

in this question the author gives some reasons about why the default keyword is introduced into java language. One reason provided is to support the optional method.

However, taking ISP into consideration, no client should be forced to depend on methods it does not use.

(from wikipedia) In the field of software engineering, the interface-segregation principle (ISP) states that no client should be forced to depend on methods it does not use.[1] ISP splits interfaces that are very large into smaller and more specific ones so that clients will only have to know about the methods that are of interest to them. Such shrunken interfaces are also called role interfaces.

From my point of view, we should be encouraged to split functions into small interfaces, without puting everything into single interface by the default trick.

Aucun commentaire:

Enregistrer un commentaire