PackageEach object contains all the information it needs to operate, and it can do its own work independently of other objects.
First, the advantages
1, the implementation of the internal class can be freely modified.
2, the class has a clear external interface.
3, has a good encapsulation, fully embodies the cohesion poly-low coupling.
Inheritancedefines the parent and child classes, which can also be called base classes and derived classes, where subclasses inherit all the attributes of the parent class. Subclasses inherit all the attributes of the parent class, and can also define new attributes.
First, the characteristics 1. Subclasses have attributes and functions that are not private to the parent class.
2. Subclasses have their own attributes and functions to extend the properties and functions that the parent class does not have.
3, the inheritance of the object represents a kind of "is-a" relationship.
4, subclasses can also use their own way to implement the function of the parent class, that is, rewrite.
second, the advantages
1, simplifies the code, is the code has been shared.
2, can make the modification or extension of the implementation is easier.
Third, shortcomings
1. The contents of the parent class are easily exposed to subclasses, which can destroy the wrapper.
2, once the parent class changes, the subclass must also be changed.
overloadedProvides the ability for a class to create multiple methods with the same name, but these methods require different parameter types.
First, the characteristics when using overloading, two methods must have the same method name, but the parameter type or number must be different.
Second, the advantages
overloading can be added on the basis of the original method without changing the new function.
Three, overloading, refactoring, rewriting the differencefirst, overloading and rewriting are similar to methods, while refactoring is a description of the soft-meter design approach that involves architecture and design methods, and overloading refers to a method that can present many forms. Multiple forms can be implemented with different parameter types or different number of parameters by means of the same name; Overrides are overrides of methods inherited from the parent class by the Generalization class, and the type, quantity, and order of the method parameters must be consistent with the method of the parent class when overridden.
polymorphicexecuted by their own code, which means that different objects can perform the same action.
features 1. The subclass appears as the parent class.
2. Properties and methods that are unique to subclasses are not available.
3, sub-class in their work at the time of their own way to achieve.
Characteristics of design pattern "hodgepodge" (I.)