1, the development of software programming technology
The software programming technology and the programming language are inseparable. Over the past few decades, programming languages have increased their support for abstract mechanisms: from machine languages to assembly language, to high-level languages, to object-oriented languages. The advent of each new programming language brings a leap in software programming methods. When assembly language appears, developers avoid using 0-L encoding directly, but instead use symbols to represent machine instructions, making it easier to code. When the size of the program continues to grow, there are high-level languages such as Fortran, C, Pascal, etc., which make writing complex programs easy and developers better able to cope with increasingly complex code, a phase of software development that is called "process-oriented." However, with the development of the software industry, larger and more complex software systems are proposed in the demand, even if the developer application of structured programming methods, it is still very difficult to grasp the overall software development situation. In this case, as a tool to reduce the complexity of development, such as C + +, Java and other object-oriented language generation, object-oriented programming also developed, software programming methodology from "process-oriented" transition to the "object-oriented (OOP)" era. It is not difficult to discover that programming techniques and programming languages define the means of communication between man and Machine [1]. Each new technology provides new ways to solve problems that have not been solved very well before. For example, the arcane 0-1 instructions are abstracted from machine-independent code: a process-oriented programming language enables people to construct more complex systems using structured design methods , the implementation details of the specific data and methods are encapsulated by the classes in the object-oriented programming language, so that the complex system can be divided into concrete. Each new technology provides a more natural way to map system requirements to programming constructs. The continuous development of programming technology enables people to create more complex systems, and vice versa, and people agree that systems with ever-increasing complexity can be used to deal with such complexities.
2, OOP concept
Oop:object-orientedprogramming (Object-oriented programming) is a programming paradigm, and at the same time a program development technique. It takes the object as the basic unit of the program and encapsulates the program and data to improve the reusability, flexibility and extensibility of the software.
Oop is a method of using object, class, inheritance, aggregation, message passing, polymorphism to construct software development, and use human's natural thinking mode as far as possible in system construction. Its basic concept [2] For example the following:
(1) object: An entity used in a system to describe an objective object, which is a basic unit of a system, consisting of a set of properties and a set of services that operate on the set of properties.
(2) Class: A set of objects with the same properties and services, which provides a uniform, abstract description of all objects that belong to the class, and contains two parts of properties and services.
(3) Encapsulation (encapsulation): Combine the attributes and services of an object into a single system unit and conceal the inner details of the object as much as possible.
(4) Inheritance (inheritance): Objects of a particular class have all the properties and services of their generic classes, called special classes that inherit from generic classes.
(5) polymorphic (polymorphism): a property or service defined in a generic class that is inherited by a special class can detail different data types or behave differently.
OOP can be thought of as an idea that includes a variety of independent and mutually invoking objects in the program, contrary to traditional thinking: the traditional program design claims to treat the procedure as a set of functions, or a series of instructions to the computer. Each object in object-oriented programming should be able to accept data, process data, and communicate it to other objects, so they can all be seen as a small "machine", or object.
3,oop's strengths
Oop technology appeared once, structured design is the mainstream of programming. Structured programming is also known as a process-oriented programming approach. In process-oriented programming, requirements are seen as a series of tasks that need to be completed, functions are used to complete these tasks, and the focus of solving the problem is on functions. The function is process-oriented, that is, it focuses on how to complete the specified task according to the prescribed conditions.
In a multi-function program, many important data are placed in the global data area so that they can be interviewed by all functions, at the same time each function can have its own local data. Figure 1.1 shows the relationship between functions and data in process-oriented programming.
Such a structure is very easy to cause the global data inadvertently by other functions modified, so the correctness of the program is not guaranteed. One of the starting points of object-oriented programming is to make up for this shortcoming of process-oriented programming. In object-oriented programming, an object is the basic element of a program that tightly links data and operations and protects the data from accidental changes by external functions. Figure 1.2 shows the relationship between objects, data, and methods in object-oriented programming.
Compared to OOP and process-oriented programming, there are other advantages of object-oriented programming [4]:
(1) The concept of data abstraction can change the internal implementation while keeping the external interface unchanged, thus reducing or even avoiding interference to the outside world.
(2) The inheritance mechanism can not only greatly reduce the redundant code, but also can easily extend the existing code, thereby improving the coding efficiency, reducing the coding error probability, reducing the difficulty of software maintenance.
(3) Combining object-oriented analysis and design, we agree to map the object in the problem domain directly into the program, and reduce the process of the intermediate link in the software development process.
(4) Through the identification and division of the object, the software system can be cut into a number of relatively independent parts, to a certain extent easy to control the complexity of software.
(5) The object-centric design can help developers to grasp the problem from the static attribute and the dynamic method two aspects, in order to realize the system better.
through the aggregation and Union of objects, we can realize the expansion of object's intrinsic structure and external function under the principle of encapsulation and abstraction, so as to realize the transformation of object function from low to advanced. Disadvantages of 4,oop
The object-oriented programming method has caused great changes in the field of software development, greatly improved the productivity of software development, and brought the light to solve the software crisis. However, as with other programming methods, object-oriented programming is not perfect. For example, the use of object-oriented programming can be very good to solve the problem of role division in software systems, the software development of a lot of concerns are modular, and these concerns can be detailed implementation details encapsulated in the class. However, there are also a number of concerns in the system that are not specific to a particular module or class, which may span multiple modules or classes, such as logging, which is referenced by many modules in the system. Object-oriented programming is not ideal when dealing with such concerns, resulting in confusion and dispersion of code [5~7]. A simple sample can be used to illustrate the problem of implementing crosscutting concerns with programming to the object, and here is a framework for implementing a class that encapsulates the business logic:
public class Businessclass extends Basebusinessclass {///Core data members//Other data members: Log stream, flag bits to ensure data integrity, method of the base class, public void Performsomeoperation (operationinformation info) {//Security verification <span style= "White-space:pre" ></span>// Check that the incoming data satisfies the protocol <span style= "White-space:pre" ></span>//lock the object to ensure data integrity when other threads are interviewed <span style= "White-space: Pre "></span>//Check if the cache is up to date <span style=" White-space:pre "></span>//record operation start run time <span style=" White-space:pre "></span>//Operation Core Operation <span style=" White-space:pre "></span>//recorded operation completed time}// Some similar operations public void Save (Persitancestorage PS) {}}
In the above code, there are two questions: first, the other data members are not the core concerns of this class; second, the implementation of the Performsomeoperation () method does a lot of things outside of the core operations, and it handles some perimeter operations such as comrades, authentication, thread safety, protocol validation, and cache management. , and these peripheral operations will also be applied to other classes. Both of these issues are rooted in the fact that OOP has failed to make the system more modular in the need to be shared by multiple modules. In order to solve the modularization realization of crosscutting concerns, a new programming technology-AOP aspect-oriented programming (aspect-orientedprogramming) came into being.
AOP Technology Application and Research series blog AOP technology application and research
Application and research--oop of AOP Technology