Directory
1. It is not considerate to design the parent class. when designing or writing child classes, it is common to find that the parent class needs to be modified and added with functions.
2. Try to avoid writing the same code multiple times.
3. Continuous Improvement
4. Several Basic Principles for evaluating Software Design
Content
1. in software design/programming, there is a basic technology called "Object-Oriented Programming ". The basic idea of object-oriented programming is object encapsulation and inheritance. The basic idea of inheritance is to extract, abstract, and put all child classes into the parent class.
This is easy to say and difficult to do. The parent class is always designed first and implemented first. A parent class generally has multiple child classes.No one can Xianzhi. It is not considerate to design the parent class. when designing or writing child classes, it is common to find that the parent class needs to be modified and added with functions. For example
Public class requestinfo {
Public dataitem getdi (string name ){
}
}
Public class dataitem {
Public String getvalue (){
}
}
When we often write
String cyccode = info. getdi ("cyccode") = NULL? Null: info. getdi ("cyccode"). getvalue ();
We will naturally think that if we add a function getdivalue () in class requestinfo, we can write shorter code:
String cyccode = info. getdivalue ("cyccode ");
In this way, the code is simpler, easier to understand, and easier to maintain.
Similarly, when we often need to get int value from Info, we naturally know that we should add getintvalue () to class requestinfo ().
2. In the process of software development, the most basic principle is to avoid writing the same code multiple times. For example:
This is a common problem caused by weeks of consideration when designing base classes. each subclass has the same code ,. The solution is also very simple. Put the common part in the base class:
3. In the software industry, like other industries, the key to making products of good quality lies in"Continuous Improvement". Continuous improvement means that if a poor design is found, it should be modified. However, in many cases, this is not easy.
For example, a company has two hundred production lines of the same type, and someone has found an improvement method to improve efficiency. We all know that it is impossible to rebuild all production lines at the same time, which has a great impact on the existing production, and there are also a lot of problems in terms of manpower and material resources. A better solution is to adopt new improvement methods for new production lines. Since the original production line can still work, it does not need to be modified immediately and can be improved gradually in the future.
This example is replaced by the software industry:
A company has two hundred software modules/classes (such as xxxbpi) with similar functions. now someone has found an improvement solution that can write less code in child classes to improve efficiency, code is easier to maintain. We all know that it is impossible to transform all xxxbpi at the same time, which will have a great impact on the existing development, and there will also be a huge problem in terms of manpower and material resources. A better way is to adopt new improvement measures for the new xxxbpi. Since the original code can still work, it does not need to be modified immediately and can be improved gradually in the future.
Therefore, there are many situations in which the old and new methods are used in large software. For example, ms SQL Server, many of the original code is bought from Sybase, MS technical experts found some ways to improve performance, after years, after multiple versions of updates, to gradually improve the old code. In open-source projects, there are also many project Release Notes stating that the original code is planned to be rewritten using a certain technology, which modules are currently completed, and which modules are planned to be added. Improvements and new features are always done at the same time.
In the preceding exampleContinuous ImprovementThe method is as follows:
4. Several Basic Principles for evaluating Software Design
The basic principles for evaluating software design are as follows: easy to understand, easy to use, stable, and functional.
Easy to understand: VB users are more understandable than VC users. There are more people who write design documents using word than those who use rose. Easy to understand means you can learn it in a shorter time.
Easy to use: if Class A and Class B perform the same function, but use Class A requires less code, we can say that Class A is better designed than Class B. Because Class A is used to write code, the code is shorter and the development efficiency is higher. Short code is easier for future maintenance.
Stability, function: the selling point of the software is stability and function. The two items are listed after the preceding bright items. The fact is that Unix/Linux has better stability and functions than windows, but it has fewer users, the reason is that it is easy to understand and easy to use.