Written for many years, C + + code, but also written for many years of Java code, C + + in order to implement efficiency, development efficiency constantly evolve, and constantly introduce new features, new Standard library. Used to develop a single function is really convenient and quick, once the UI and the complexity of the function, the C + + library is not enough. With its simple syntax, memory management, and cross-platform advantages, Java has won the first place in the programming language for many years.
In the field of Android development, because it is open to C + + features similar, resulting in a lot of fragmentation, for the user is blossoming, for the developer is more work (more jobs).
In the end, said refactoring, involving the refactoring of the target specification, although Java code refactoring, the following major principles are suitable in many languages and many other fields.
Here's the moving one.
The six principles of the design pattern (each of the principles look so big on the name)
1. Opening and closing principle (Open Close Principle)
a software entity such as classes, modules, and functions should be open to extensions and closed for modification.
2. The principle of substitution on the Richter scale (Liskov Substitution Principle)
Subclasses can extend the functionality of the parent class, but cannot change the original functionality of the parent class.
3. Dependence reversal principle (dependence inversion Principle)
The core idea is to interface-oriented programming, that is, to call functions or pass data through an interface as much as possible.
4. Interface Isolation principle (Interface segregation Principle)
establish a single interface, do not set up a huge bloated interface, as far as possible to refine the interface, the interface of the method as little as possible.
5, Dimitri Law (least known principle) (Demeter Principle)
A class knows as little as possible about a class that it depends on.
6. Single Duty principle (Responsiblity Principle)
A class is responsible for only one responsibility
According to the above design principles in the design of modules or interfaces, there are the following principles and techniques (a bit like talking about the truth of Life):
1. Stability
Must be relatively stable, if very small changes in functionality caused the interface changes a lot, this stability is not enough.
2. Ease of Use
The functions provided to external use should be clearly understood, i.e. function names, invocation parameters should be as intuitive and simple as possible, i.e. self-describing functions.
3. Completeness
In addition to the function of the module, there should be fault-tolerant, exception handling and other functions.
4. Cohesion
That is, their own things to do, less to rely on others.
Android Refactoring Random Thoughts