Nature bug, human bug, software's incurable disease

xiaoxiao2021-03-06  39

"Every spring, summer, Qianhe Yun Ji" Qingcheng Mountain, in this habitat, the cranes that have lived last millennium, they have been disappeared. Local residents have accused: This is the disaster of real estate development! Maybe not this, maybe; there is a climate abnormality in many countries around the world, there is no fundamental way to prevent it, may not.

The maximum BUG of human beings is cancer, as well as AIDS, SARS, etc. There is no fundamental prevention method, and it can not be found.

It will always encounter many suspected diseases, some are solved, and some cannot solve. Let's compare for several reasons and solutions:

Dead habit

There is a natural law, and the accumulation of bad habits has led to natural illness, people are sick. Poor programming habits will also cause problems in programs.

Example 1.1 Middleware Memory Problem

When a Delphi middleware performs bulk data processing, the memory increases, and the memory accounts for nearly 1G after a few hours, and the memory is not reduced. The memory tool such as Turbo MemorySluth did not find the problem. Finally, the most original method: Do the allocMemsize before and after a piece of code, see the difference, normal should be zero, Isolated a piece of code will leak 100K left and right memory. , Just because the code you created by the code did not release, it was released. This problem has been checked for a long time. If the author of this code is accustomed to the object you created, you will not need multi-person cost machine to track findings, and have problems with ADO, MIDAS, and three-layer structure.

For programmers, many things are not wrong, just habits, such as following naming customs writing practices, write comments, using try ... finally ... End to ensure resource release, etc., bad habits The accumulation of bad habits Finally, the software does not appear It is easy to find trouble, good living habits will mean good quality of life, good programming habits will also make good product quality.

2. There is an unknown

Compared with nature, people are simply simple, but they can be called complex systems. One person can only understand part of a complex system in a specific time. If you want to use unknown things, it is likely to have problems, just like people, although we have many unknown things for yourself, but it is often sick. Regular problems.

For unknown things, we can do it, trust and use it in a natural way and understand it, or directly transfer to known things, and then it is true to judge what it should be, should be so do.

Example 2.1 MDB can't open a problem

A stand-alone software uses the Access database to publish the user after running, it is always prompted to open the database exclusively, but there is no other person, the problem is also looking for a long time, suspected of virus, anti-virus, etc., finally knows just because MDB file properties It is read-only, released the disc, and it is still read only after copying to the user's machine.

I don't know if it is only because of the reason, it is difficult to get it. Of course, this can also be said to be software defects, it should have more friendly tips, maybe written in this code of this code, there is no consideration, maybe write in the document, but we don't know. The unknown of the programmer is always a lot. It is always a lot of problems, but we still have to use these things that you can't grasp.

This world must be reused, everything is reused, such as a woman, and a man.

Example 2.2 SaFECALL problem

One intermediate remote module uses Wrapper mode (or delegate mode), transfer the call to the corresponding class, such as

// Remote module code does not implement method

Procedure trdmmyremoteDataModule.myProc; // must be declared as SaFecallbegin in Interface

FmyClass.myProc;

END;

// Specific implementation in another class

Procedure TMYCLASS.MYPROC; // also declared in Interface as SaFECALL

Begin

Raise Exception.create ('Just A Exception');

END;

The results found that an exception could not return to the client. Another class write the same code, there is no problem, and the exception can throw to the client. When writing the correct code, I don't understand why I don't add SafeCall, which may just do the right thing because I intuken.

Finally check Delphi help, I understand: "The SafeCall Convention Implements Exception" FireWalls. "...".

At the same time point, different programmers may have the same unknown, some can directly take the right road, some of the wrong way, I don't know what is the truth, I can only accumulate the intuition of years of experience.

Example 2.3 ADO

V2.7 or lower version of the ADO, Delphi executes the following parameters of the SQL will be wrong: "SELECT * (Select * from T where f =: p) a", there is no problem in 2.8. Find this problem a lot of discounts. First, a very complex SQL total error, then simplify the above or wrong, suspect is related to the ADO version, find the main file version 2.70, 2.71 no problem, want to replace the ADO support file (Program files / Common Files / System / ADO, the result is successful, then discovers that the file is restored to an old version, and finally after the shell is removed, the file is replaced in the command line, the operating system is really a huge virus. Direct upgrade to ADO2.8 can also.

In fact, developers, users, customer service staff are all the same, find problems, they are ideas to upgrade software to high versions, do not understand why, maybe the problem is solved. I don't understand too much, but I don't know that the programmer can't stop the problem. Many times solve the problem, I don't know if I don't know. Only if there is an effective thing.

The problem confirmation is that after the ADO processing parameter problem, we replace the ZEOS-based code to process parameters to plug the parameter value directly into the SQL to form a complete string, which is convenient to debug, optimize SQL, and solve another more complex SQL The problem of Access Violatioin error occurring during ADO2.8 is executed.

3. Structure problem

A large natural engineering, such as dam, etc. If there is a problem, the impact may not be the environment, it is also very difficult. If there is a problem with the structure of the person, what is wrong with it, it is very painful. Software If there is a structural problem, it is also very painful. However, software is natural, people are different, software is easy to push down.

Example 3.1 98 Memory Problem

A Delphi program runs in 98, there is no problem, but there is no problem in other operating systems; another program can perform files but no problem. It is found that there are too many problems in the program, and you can lose a few. Later, the reason is that there are too many resources in the executable. The resources need to be a handle space of the system, and 98 only 64K user resource handle space, so as long as the other bitmaps that are not used in the executable are deleted. Yes. The RAD development mode provided by Delphi, in addition to the VCL is very nice stuff, others are not good: the form uses a separate resource save, the event code is written directly in the unit of the form, and the latter directly leads to the interface and logic. Separation, the former There is no such thing in Delphi8 and .NET. The interface and logic separation can bring excellent structures to the program, in fact, Delphi has provided such mechanisms, such as based on Action. In new development, we have introduced dynamic forms, separating interfaces and interface logics to forms, business logic writes in Action, clearer structure means greater extension space and fewer problems, smaller Maintenance cost.

4. Environmental changes

Animal and people will have an abnormal behavior when the environment changes. People may not serve in new environments, and software errors will also have different performances in different environments.

Example 4.1 "Disaster Fault"

Three-layer software in the client newspaper Chinese "catastrophic fault" error, it is found because the middleware appears AV (Access Violatioin) error, AV error is caused by bad habits or unsafe code, such as empty objects ( Pointer) Access, release empty objects or object repeated release, etc.

Another possibility that the client is "catastrophic fault" is that the middleware has a floating point number operation error, such as divided by zero, and the floating point value cannot be filled in the "Invalid Floating Point Operation" wrong of the database field. It is also because of unsafe code, the former is not judged before the floating point number, the latter may not do initialization because the variables in the stack are used.

The code to write secure is like a person who is practicing Jin Kong, and it will not be faulty when the external environment changes.

转载请注明原文地址:https://www.9cbs.com/read-53490.html

New Post(0)