Application and Research of AOP technology -- OOP and aop technology application -- oop

Source: Internet
Author: User

Application and Research of AOP technology -- OOP and aop technology application -- oop
1. Development of Software Programming Technology

Software Programming Technology and programming language are inseparable. Over the past few decades, programming languages have continuously increased support for abstract mechanisms, from machine languages to assembly languages to advanced languages to object-oriented languages. The emergence of each new programming language brings about a leap in software programming methods. When the Assembly language appears, developers do not directly use 0-l encoding. Instead, they use symbols to represent machine commands, making programming easier. When the program scale continues to grow, there are advanced languages, such as Fortran, C, and Pascal, which make it easy to compile complex programs, developers can better cope with increasingly complex code. Software development methods at this stage are called process-oriented ". However, with the rapid development of the software industry, larger and more complex software systems are proposed in the demand. Even if developers use structured program design methods, it is still difficult to grasp the overall situation of software development. In this case, as a tool to reduce development complexity, object-oriented languages such as C ++ and Java have been generated, and object-oriented programming has also developed, the software programming methodology also transits from process-oriented to the object-oriented (OOP) era. It is not hard to find that programming technology and programming language define the communication mode between people and machines.[1]. Each new technology provides some new methods to solve the problems that have not been well solved. For example, machine-independent code can be used to abstract obscure 0-1 commands: process-oriented programming languages allow people to use structured design methods to construct more complex systems; by encapsulating the implementation details of specific data and methods through classes in object-oriented programming languages, people can divide complex systems in detail. Every new technology provides a more natural way to map system requirements into programming structures. The continuous development of programming technology allows people to create more complex systems, and vice versa. People allow more and more complex systems because new technologies can be used to deal with this complexity.

2. OOP Concept

OOP: Object-Orientedprogramming (Object-Oriented Programming) is a programming paradigm and a programming technology. It uses objects as the basic unit of a program and encapsulates programs and data to improve software reusability, flexibility, and scalability.

OOP is a method to construct software development by using objects, classes, inheritance, aggregation, message transmission, and polymorphism. It tries its best to use human natural thinking methods in system construction. Its main concepts [2] are as follows:

(1) object: an object used to describe objective things in the system. It is a basic unit of the system, an object consists of a group of attributes and a group of services that operate on these attributes.

(2) class: a set of objects with the same attributes and services. It provides a unified abstract description for all objects of the class, it includes attributes and services.

(3) encapsulation: combines object attributes and services into an independent system unit, and hides the internal details of objects as much as possible.

(4) inheritance: Objects of special classes have all the attributes and services of their general classes. They are called special classes that inherit general classes.

(5) polymorphism: Generally, attributes defined in a class or services inherited by special classes can have different data types or show different behaviors.

OOP can be seen as an idea that contains various independent and mutually called objects in a program. This is just the opposite of the traditional idea: in traditional programming, a program is regarded as a collection of functions, or directly a series of commands issued to computers. Every object in object-oriented programming should be able to accept, process, and transmit data to other objects, so they can be considered as a small "machine", that is, an object.
3. Advantages of OOP

Before the emergence of OOP technology, structured design was the mainstream of program design. Structured Programming is also known as process-oriented programming. In process-oriented programming, requirements are considered as a series of tasks that need to be completed. functions are used to complete these tasks and focus on functions to solve the problem. The function is process-oriented, that is, it focuses on how to complete the specified task according to the specified conditions.

In multi-function programs, many important data is stored in the global data zone, so that they can be accessed by all functions, and each function can have its own local data. Figure 1.1 shows the relationship between functions and data in process-oriented programming.

This structure can easily cause global data to be accidentally modified by other functions, so the correctness of the program is not guaranteed. One of the starting points of object-oriented programming is to make up for the disadvantages of process-oriented programming. In object-oriented programming, an object is a basic element of a program. It closely links data and operations, and prevents data from being accidentally changed by external functions. Figure 1.2 shows the relationships between objects, data, and methods in object-oriented programming.


Comparing OOP and process-oriented programming, you can also obtain other advantages of object-oriented programming [4]:

(1) The concept of data abstraction can change internal implementation while keeping external interfaces unchanged, so as to reduce or even avoid external interference.

(2) The Inheritance mechanism can not only greatly reduce redundant code, but also easily expand existing code, which improves the coding efficiency and reduces the coding error probability, reduce the difficulty of software maintenance.

(3) combined with object-oriented analysis and design, objects in the problem domain can be directly mapped to the program to reduce the conversion process of intermediate links in the software development process.

(4) through the identification and division of objects, the software system can be divided into several relatively independent parts, which facilitates the control of software complexity to a certain extent.

(5) the object-centered design helps developers grasp problems from both static attributes and dynamic methods to better implement the system.

Through the aggregation and Union of objects, the internal structure and external functions of objects can be expanded under the principle of encapsulation and abstraction, so as to realize the transformation of object functions from low-level to advanced. 4. disadvantages of OOP

Object-Oriented programming methods have caused significant changes in the field of software development, greatly improving the productivity of software development and bringing light to solving the software crisis. However, like other programming methods, object-oriented programming is not perfect. For example, the use of object-oriented programming can effectively solve the problem of role division in software systems and modularize many of the concerns in software development, and encapsulate the implementation details of these concerns in the class. However, there is another type of attention in the system. They are not specific to a certain module or class. They may span multiple modules or classes, for example, the log function can be referenced by many modules in the system. The method used by Object-Oriented Programming to deal with such attention points is not ideal, resulting in confusion and decentralization of code [5 ~ 7]. You can use a simple example to illustrate the problems caused by cross-concern implementation by programming to the object. Here we provide an implementation framework that encapsulates the business logic:

Public class BusinessClass extends BaseBusinessClass {// core data member/other data member: log stream, public void metadata msomeoperation (OperationInformation info) {// security verification <span style = "white-space: pre "> </span> // check whether the incoming data meets the Protocol <span style =" white-space: pre "> </span> // lock the object to ensure data integrity when other threads access <span style =" white-space: pre "> </span> // check whether the cache contains the latest information <span style =" white-space: pre "> </span> // record the operation start time <span style =" white-space: pre "> </span> // perform core operations <span style =" white-space: pre "> </span> // recorded operation completion time} // some operations similar to public void save (PersitanceStorage ps ){}}

In the above Code, there are two problems: first, other data members are not the core concerns of this class; second, the implementation of the performSomeOperation () method has done a lot of things beyond the core operations, it handles peripheral operations such as comrade, verification, thread security, protocol verification, and Cache Management, and these peripheral operations are also applied to other classes. The above two problems are ultimately caused by OOP's failure to modularize the requirements that are shared by multiple modules in the system. To solve the modular implementation of cross-cutting concerns, Aspect-OrientedProgramming, a new programming technology, came into being.





Differences between Aop and oop

AOP is for cutting-edge programming.
Oop Is Object-Oriented Programming
Concise enough

I want to know the differences between OOP and AOP.

AOP-Aspect Oriented Programming: Aspect-Oriented Programming. It is essentially different from object-oriented Programming. However, the two are still very different in their design ideas.

AOP focuses on a certain step or stage of the business processing process, and emphasizes reducing the coupling between modules to make the code more portable.
Object-Oriented Programming (oop) encapsulates methods and attributes of entities extracted from business analysis. It can also be said that AOP is oriented to the verb field in the business, and OOP is oriented to the noun field.

An important feature of AOP is source code independence. That is to say, if we reference the AOP component in our system, the system code should be compiled even if we remove the component. To achieve this, you can use the dynamic proxy mode.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.