The objective with the design patterns you employ in your project is to find solutions to problems that arise, and with these solutions, to ease the lives of those in the software world and to make the developed project more usable. Another definition is the categorization of objects that are frequently used in projects for reuse.
Design Pattern, which generates solutions for different problems, has 23 patterns that are most commonly used in the industry.
Let's mention a few key features of design patterns:
They have a reusable structure.
They solve bigger problems in common uses.
They have emerged as a result of experience, hence they offer significant advantages in use.
Design Patterns are divided into various categories among themselves:
Creational Design Pattern
Behavioral Design Pattern
Structural Design Pattern
Before these, we can explain what MVC is, a concept that is frequently heard. Model (Data-Database), Interface (View), Middle Layer (Controller) is the most preferred architecture today that combines these panels.
What is our purpose for using this Architecture?
When you are developing an application, you can see the convenience these three layers provide in software.
The Model layer is the part where the databases within your application are located, allowing you to manage your data easily in this area.
The View layer is generally the section where the user interacts.
The Controller enables you to perform operations between the Model, which is the first layer, and the View layer.
If we give an example of this structure, it allows you to make changes easily only on the layer you want to edit, eliminating the possibility of breaking all the codes in a part of the interface you want to change in the application you wrote later.
We can define a few of the categorized Design Patterns. The first one being Creational,
Abstract Factory carries the name of the abstract factory in Turkish. Rather than obtaining separate Classes while implementing the same interfaces in your application, creating Classes attached to this factory, like a central factory, will help make the software more flexible and operational.
Builder, although somewhat similar to Abstract Factory, it facilitates the system to only specify object types when creating complex objects. The use rate of the Builder pattern is around 40%. The reason for this low rate is that it is harder to identify suitable solutions compared to other patterns.
In the other category, Behavioral Design Patterns,
Mediator Pattern is known as the intermediary template and generally aims to manage classes that have too much interaction with each other in system controls, usually through a single class.
The Iterator Pattern is the iterative template. It leaves it to this pattern to decide according to which order the tree structure in the object integrity will act.
Lastly, Structural Patterns,
The composite design pattern organizes the tree structure within the object hierarchically.
Facade Pattern reflects the characteristics found in its subclasses. It has the same features. When implementing a class, combining them in a common structure and applying them by creating a structure with the same features under a new name or allowing you to use them separately if you wish.
In our future articles, we will talk about examples using design patterns on the ABAP side.
Also, if you want to do more detailed research on design patterns in object-oriented programming, I can recommend the book "Design Patterns: Elements of Reusable Object-Oriented Software by Gamma, Helm, Johnson, and Vlissides."
Design patterns allow you to easily design your algorithms and make your coding more stable and faster. You can use them with classic ABAP, which we call procedural coding technique, as in object-oriented programming.
The benefits of using design patterns while programming in ABAP;
It reduces complexity during the design process, allows us to control the process, and ensures manageability, no matter how complex the modules and programs we will write are.
For example, adding BAPI on top of the material creation BAPI in sectoral solutions while creating materials with BAPI.
From a maintenance perspective, calling a variable you changed in one place or a table you “selected” at the same point by a method or function throughout the module, or facilitating your management in “key” changes in the table. You can put your BADIs at these points in your products.
In team works, different people working at different points, working around the same template, can enable fast and effective coding. It allows programmers to change roles among themselves very quickly. Alternatively, in a program, one developer working on functions and classes on the "model" and "controller" side, and another developer designing screens on the "view" side is an example of team work.
You can reach my article on "singleton pattern" from this link.
Süleyman Çelik
F&R EWM ECC S/4 HANA ABAP-OO Developer / FIORI / Solution Architect
Comments