A few years ago, SAP basis 4.6 extended the OO function for ABAP, which is a traditional ABAP Program Members are in trouble. First, for ABAP programmers, they can finally use the OO development method to gain potential value to improve development efficiency and maintainability of the developed program. However, abaper, who has been accustomed to process-oriented programming, is not so easy to quickly switch to the OO model. Many people still stick to the traditional process-oriented development model, they think they can get what they want without oo. This article Article The main purpose is to let you understand what oo can bring to you and how to transform to the OO model.
Many articles on ABAP oo are either too abstract, or the examples are too simple to be irrelevant to practical applications. This article attempts to illustrate the advantages of OO by comparing process-oriented and object-oriented models with simple and practical examples.
1. First, abap oo has a higher level of data encapsulation, which enhances the maintainability and Stability of the program. In process-oriented mode, the global variable area of a program contains many irrelevant variables. These variables are intertwined in one region, in this case, a major component of the Program changes the program State and is not known to another function in the program. To maintain the stability of the entire program, a large amount of constraints and maintenance costs are required. In the OO mode, the state is saved on the object. Objects can be separated from external data and methods to ensure that functions (Methods in OO) can only change data related to them, and the attributes of objects are not changed, this ensures its stability in applications.
2. ABAP oo can implement multiple instances of a class. (The object is composed of data and operation data methods .), Each object has its own attribute values defined in the class, and its status can be changed through its own methods. This means that developers do not need to establish a connection between data and methods for each object or manually manage the lifecycle of each object. There is no multi-instance concept in process-oriented methods, and data and functions are separated from each other. You are using a stateless function, and each time you need to initialize it by passing parameters, and manually clear the memory occupied by it.
3. ABAP object further enhances the program through inheritance Code This is an important aspect of object-oriented methods. With this feature, you can reuse part of the inherited class or all methods. You only need to write the method specific to the class, which reduces the number of methods written for each class, this enhances the maintainability of the program. For process-oriented programming, you will be subject to the situation of all-or-nothing. You can either call all the parts or create a new one.
4. ABAP oo allows you to call the business logic of an object through interfaces rather than directly using objects. This avoids the need to know the specific functions of each object in detail. In this way, you do not need to modify the interface content when you need to modify a function. This also provides a new way to modify the standard program, namely, Badi. Process-oriented programming does not provide this opposite interface to relate to an object-the interface is implemented only through the parameters of form or function module.
5. ABAP Oo is easily combined with the event-driven mode. Different applications are loosely coupled by publishing and booking. Callers and callers are not passively bound together. This method is more flexible than the process-oriented method. Their binding is tight and the execution process of the program is predefined.
Of course, all these benefits can be achieved only when you re-develop them in the future using the OO method. However, re-modeling the development model of your application is frustrating and troublesome. We promise this will not happen. After reading this article, we believe you will come to the same conclusion. Of course, we didn't say we need to re-model the existing applications. We just hope that you will finally consider the OO model in the future development process.
If you insist that the process-oriented model is sufficient for you, continue to read it. By using the object method instead of form and function module, you can still enhance your ABAP program.
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.