Keywords: non-invasive
First we need to know what an intrusion interface is, such as defining the interface person Interface: Fight (), Play (), Zhimaoyi (), Zuofan () method Women Interface: Zhimaoyi (), Zuofan () Method Man Interface: Fight () , Play () method The Classperson class implements all the methods of the person interface
- In the traditional OO programming language, in order to get a man object, at least write a Classman class to implement the man interface, in order to get a women object and have to write a classwomen class to implement women interface, Similarly, to get a person's object to do so, it is clear that the code is not a high rate of reuse
- Or so design interface,Fight,play,zhimaoyi,zuofan and other basic interface, man interface inherits from Fight,play interface, women interface inherits from Zhimaoyi, Zuofan interface, This is an intrusive interface design (although not yet, but this is common in traditional oo design, and more complex than this)
the non-intrusive interface of go does not inherit this concept at all:Classperson implementation of the person interface, in fact, Classperson also implemented the Women interface and man interface defined methods, so in go, the following way is legal is also recommended var man man = new (Classperson) var Women women = new (Classperson)
In the traditional OO design, the interface is strong, rather than the intrusion-type interface design is more flexible, more practical, not to be continued ...
The study of Go language learning note---non-intrusive interface design