The author describes the development of the programming language from an abstract perspective. The Assembly Language is the abstraction of the underlying machine, and the process language is the abstraction of the assembly language, both languages are used to describe machines, and programmers must be responsible for building bridges between problem spaces and space.
As a result, people try to build a problem space model directly on the machine, and the object-oriented language came into being. Object-oriented language uses objects to simulate things in the real world, so it has the various features it needs like things in the real world.
In this context, objects must have their own classes, so the concept of class is introduced. An object must interact with the outside world. Its interface is a class function. In order to control the connection between the class creator and the class user and improve the module independence, necessary encapsulation is indispensable.
Implementing code reuse is a major issue in the programming world. Therefore, object-oriented languages use combinations to reuse the implementation of classes and introduce inheritance to reuse class interfaces. To reuse the customer code of the class, polymorphism is essential.
When talking about objects, we can't help but talk about the creation and destruction of objects to control their survival and storage areas. The design goal of the C ++ feature is efficiency first. It is flexible and variable, but the memory management mechanism is complicated. Unexpected handling is a big problem in the actual project. The standard C ++ feature is greatly enhanced in this respect, so that errors can be handled in the language and be restored to normal.
The author will introduce the process of software analysis and design in a large space. Ready-made methods are designed for the most complex scenarios. We only need to use a small part, which is enough. In general, the author advocates that the program be run as soon as possible through a brief analysis.
Take the most important part and the most risky part as a priority and take out a test version as soon as possible. Of course, encoding is not started directly, even a simple analysis is much better than directly starting encoding. But do not fall into details too early, and the analysis cannot be completed in one step.
There are always some factors that can be discovered only in the coding or even testing phase. To what extent should analysis be done? For object-oriented programming, it is necessary to find out what objects have and what interfaces they have. You may need more descriptive information, but you must never cut it down. The entire process can be divided into five steps:
0. Develop a plan. Opening a program directly is also a kind of plan, but adding a few milestones is often more motivating to programmers, and there is more opportunity to celebrate. Here, we can summarize the entire system with a few highly abstract sentences. In the future, we will feel that it is not accurate enough to make changes.
1. What to do. That is, requirement analysis and System Specification Description. These documents are usually discussed, so the simpler the better. The author suggests using use cases. A use case reveals a function of the system, including its response in various situations. Use cases should be as simple as possible, so as not to be troubled by some details too early. Next, we should make a time schedule, and estimate the time faithfully as much as possible. Multiply by 2 and add 10%, and the task can basically be completed well.
2. How to do it. We recommend that you use a CRC card and a 3-by-5 card to record the name, function, and interaction of a class. Card space is limited to avoid getting into details too early. It allows you to have a preliminary understanding of the entire system as soon as possible and facilitate discussion. You can also use UML. The Design of objects is generally divided into five stages: Object discovery, object assembly, Object Construction, system expansion, and Object reuse. New classes may appear in each stage, so do not expect to propose all classes at this stage. The principle of object development is that a class only solves one problem. The main task of system design is to implement the required class. Do not force one step to get started as soon as possible.
3. Create a kernel. Only the necessary and risky components for the system to run can be seen as soon as possible.
4. Iteration case. One use case is added for one iteration and gradually improved.
5. evolution. Perfect for future use.
The most prominent of various analysis and design methods is extreme programming, which affects many methods. The two most important aspects are writing test and Pair Programming first. Writing and testing can force programmers to provide complete and clear class interfaces and automatically test each time a system is created. From the perspective of detection, the progress of programming languages is the progress of detection.
The assembly language can only check syntax errors. The C ++ feature can also detect semantic errors, while the object-oriented programming language is more rigorous. Despite this, some errors can only be found during running. Therefore, we need to add some test code to ensure the correctness of the program. Pair Programming allows one person to write code, and the other person to consider the global situation. Once the encoding cannot proceed, the code can be exchanged and discussed together.
- Differences between standard input implementation methods in C and C ++
- How does the C ++ compiler allocate storage space for Const constants?
- Basic Conception and method of C ++ Class Library Design
- Several Methods for converting C ++ Language
- How to better compile C ++ code