ABAP Design Patterns

ABAP design patterns section covers the uses and implementations of design patterns in ABAP Objects. The ABAP design patterns are extremely powerful blueprints for ABAPers or SAP Architects in design phase of SAP development projects. ABAP design patterns allow common problems to be solved through proven and well-known solutions. In addition, ABAP design patterns ensures correct ABAP code is developed faster with less mistake that will occur in both design or implementation phases.

We assumed that you have basic knowledge of ABAP Objects and to be familiar with UML to follow our ABAP design patterns tutorial.

ABAP design patterns are grouped into three categories: creational patterns, structural patterns and behavioral patterns. Let’s dive into each individual design pattern and see how it works.

Creational Patterns

  • Factory Method – Makes use of factory method to create an instance of appropriate class from class hierarchy or family of related classes when the client does not know which class to instantiate.
  • Singleton - Provides an object creation mechanism to ensures that one and only one instance of class exists.
  • Abstract Factory – Allows creation of object from a suite of related classes without specifying the actual concrete object to be instantiated.
  • Builder – Enable to create a complex object by providing information on only its type and content, keeping the details of object creation transparent to the clients. The builder pattern allows the same construction process to make different representations of the object.
  • Prototype – Offers a simpler way of creating object by copied or cloned it from existing (prototype) object.

Structural Patterns

  • Adapter – Adapts interface of an existing class into another interface that clients expect.
  • Bridge – Decouples an abstraction from its implementation to allow the two can vary independently.
  • Composite -  Enables both individual objects and composite objects to be treated uniformly.
  • Decorator – Extends functionality of an object dynamically without modifying its class or using inheritance.
  • Facade – Offers an easier to use interface to a subsystem of classes.
  • Flyweight – A fine-grained instance used for efficient sharing.
  • Proxy – Provides an object that represents another object.

Behavioral Patterns

  • Observer – Ensures related objects get notified when the state of an object changes.
  • Strategy – Encapsulates individual of algorithm in a family of related algorithms and make it easier to interchange the  alternative implementations, even at run-time.
  • Chain of responsibility – Allows the sender object to pass the request along a chain of objects without knowing which actual object will handle the request.
  • Command – Allows requests are encapsulated as objects, thereby enable clients to be parameterized with different requests.
  • Interpreter -  A way to include language elements in a program.
  • Iterator – Allow clients to traverse the contents of a collection of objects sequentially, without having any knowledge about the internal representation of its content.
  • Mediator – Defines simplified communication between classes
  • Memento -  Captures and restore an object’s internal state.
  • State – Allows object to change its behavior when its state changes.
  • Template Method – Lets subclass handles exact steps of an algorithm.
  • Visitor – Enables adding new operations to a class without change.

Enjoy ABAP design patterns tutorial