What is the principle of java interface isolation?
This article mainly explains "what is the principle of java interface isolation". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what the principle of java interface isolation is.
Interface isolation principle (ISP), The Interface Segregation Principle
Define
Clients do not need to be forced to rely on interfaces they do not need.
The dependency of classes and interfaces should be recommended on the smallest interface, that is, the interface should be minimized and should not be built on a large interface, which is reasonably divided into several single subinterfaces according to their functions.
If an interface defines and publishes too many methods, all implementation classes must implement the methods of the interface, and different business scenarios may not need to be implemented, so the principle of interface isolation is to implement only the interfaces they need.
For example, BeanFactory in spring defines the most basic operation methods of bean, while there are three extended sub-interfaces under BeanFactory. The extended sub-interfaces have all the methods of the parent interface and have their own unique methods. We can directly implement the parent interface or the sub-interface as needed, thus achieving the principle of interface isolation and minimizing the interface.
It seems that the principle of interface isolation is not difficult to implement, as long as it has a little business abstraction ability to do so, the principle of interface isolation also meets the principle of single responsibility on the one hand.
Thank you for your reading. the above is the content of "what is the principle of java interface isolation". After the study of this article, I believe you have a deeper understanding of what the principle of java interface isolation is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!