When I searched for this concept on the internet, I found that there were very few such articles in China. A foreign book with the same name was published, but I did not read it. So this concept is basically self-fabricated by myself, but the Internet also has the same name.
Let's talk about what interfaces are. This is an old problem, but it must be clearly defined before design. A common definition is that an interface is a contract. I think this definition is very vague. A contract indicates that both parties have certain legal or moral effects. However, first, the Chinese do not often set contracts, so they are not very familiar with the essence. Second, this definition still does not define the content features of the interface. Therefore, many people still do not understand this definition. This definition may not meet national conditions or public opinions. I prefer to define interfaces as duties (or roles and capabilities ). Responsibility is the power and obligation granted under certain circumstances. In the social application field, the concept of using roles is more deeply rooted in the hearts of the people. Use the Role word in English. In general, the capabilities are acceptable to everyone. Let's make an analogy. In object-oriented analysis, we analyze a person's objects. In this example, we assume that an instance is Han Xiaoming. How many interfaces should Han Xiaoming implement? He works in the company and needs to write code, so he must have the encoding capability. Sometimes you have to participate in the design, so you must have the design capability at the same time. He has a family and must be responsible for the family. If you have a wife, you must be able to be a husband. Of course, the above capabilities can also be understood as roles. Software engineers, architects, husbands, children, fathers, etc. Is it necessary to implement so many interfaces for a person (object) like Han Xiaoming who has multiple roles at the same time? It depends on what our business involves. If we only care about his work, it will only involve the software engineer and architect roles (interfaces ). The interface-oriented design started to play a role at this time. In the UML design, it actually involves the interface design, that is, the Role, but it does not specifically design the Role itself, but it only exists as a relationship. Methods are transferred to the object. In a certain sense, the interface design is ignored. Repeat the OOA/OOD process, analyze the object, analyze the object attributes statically, and dynamically analyze the object methods. If we add the interface analysis and design process, our process becomes: analyze the object, analyze the attributes, analyze the interfaces (roles and capabilities), and analyze the methods. This set of interfaces is located between classes and methods, and is a very good analysis tool. As for some of the principles and methods for interface-oriented design, I believe it will be a wonderful article. Looking at our most basic software design before we are overwhelmed by new concepts, we often find some unexpected gains. This is also true for interface-oriented design. I hope these gains will also help you. Original article: http://blog.csdn.net/xiammy/archive/2006/11/25/1413244.aspx::《interface Oriented Design
Http://www.oebook.com/search.asp? Sort = ebook & keyword = Interface + Oriented + Design & language = en & Submit = search