The perfect choice of one-stop service for diversification of architecture.
When a class inherits an abstract class, non abstract methods and attributes inherit, and the abstract method helps to implement them.
Class is like a modular machine when using the interface. If you install an audio interface, you have to do a power amplifier function inside. After the design, you have to have what functions according to what interface.
2. Structure:
An abstract class is more like a tree structure. The scope of an abstract class is the following subclasses, and there is no need to manage anything else.
The interface is more like an inter layer structure. The communication method between the upper layer and the lower layer is this interface. The upper layer can call according to the interface if it wants.
3. In terms of logic:
According to the logical order, the interface is generally designed first, and then the class is written. Because there are more classes, the abstract class is abstracted, which is convenient to write more classes.
The interface defines the functions of the class, and the abstract class abstracts the characteristics of some classes.
4. In terms of code writing:
Abstract classes improve the cohesion of classes and generic classes and reduce the amount of code.
The interface reduces the coupling between classes, but increases the amount of code.