Done twiceCodeBoth Java and. Net were reviewed for about three hours. The biggest achievement is to separate the scheduling method from the atomic operation method.
The scheduling method is generally a method that calls other methods to implement a function based on different situations.
The scheduling method reflects the process.
The atomic operation method is generally a method with a single function. It only completes one simple function and will be scheduled by the scheduling method.
Atomic methods reflect atomic operations.
The effective differentiation between the two methods is an important way to improve the code quality.
When we began to focus on code quality, we defined many rules, such as variable naming and constant definition.
These rules should be the most basic requirement that developers must comply with. These rules can be checked through some auxiliary check tools. After these rules are executed, the code readability and maintainability increase.
However, these rules are too detailed and will not bring about a qualitative leap in the Code itself.
On this basis, we need to better think about Code rules and organize high-granularity Code rules, which brings a qualitative leap.
Let's take a look at the example below.
// This is the scheduling method.
Private collectiontablevalue savevalue (collectiontabledata data)
{
// The stub method of this atomic method can be generated through the refactoring function provided by. NET and Java.
// Obtain the value if it already exists
Collectiontablevalue objctvalue = getfiledvalue (data );
If (objctvalue! = NULL)
{
// Update an existing value
Objctvalue = updateexistvaue (objctvalue );
}
Else
{
// Create a new value
Objctvalue = createnewvalue (data );
}
Return objctvalue;
}
// These are all atomic methods.
// These are all automatically generated Methods
Private collectiontablevalue getfiledvalue (collectiontabledata data)
{
Return NULL;
}
// These are all automatically generated Methods
Private collectiontablevalue updateexistvaue (collectiontablevalue objctvalue)
{
Return objctvalue;
}
// These are all automatically generated Methods
Private collectiontablevalue createnewvalue (collectiontabledata data)
{
Collectiontablevalue objctvalue = new collectiontablevalue ();
Return objctvalue;
}
If we add:
Layered requirements: A layer is the method for adding, deleting, modifying, and querying data operations.
One layer is to process the business logic
One layer is external proxy
The elegant structure and the elegant code make our quality soar. Most importantly, we can save a lot of debugging time, perform lengthy quality work to improve quality, and greatly reduce costs.
The capabilities of developers will also be improved.
Developers do not need to work overtime either, because the code quality is improved and it naturally takes more time. You can read books, exercise, and so on.
It is easy for the quality personnel, because the quality is improved and there are fewer useless checklists.
The project cost is reduced, and the project manager's day is better.
As the company's profit increases, revenue is about to rise. (Pretty beautiful :))
Source: http: // 192.168.101.8/blog/040706/archive/2006/07/15/4595 .html