May 2019
Beginner to intermediate
548 pages
12h 39m
English
The purpose of the Prototype Pattern is to offer the option of creating multiple classes based on one class: a prototype. This pattern can be created when we want a large number of objects of the same type or when we need to create a collection of almost the same object.
Here's an example implementation of a prototype in ABAP:
The zcl_car class is the class that creates an abstract definition of new cars:
CLASS zcl_car DEFINITION ABSTRACT. PUBLIC SECTION. METHODS: clone ABSTRACT IMPORTING iv_color TYPE string RETURNING VALUE(ro_object) TYPE REF TO zcl_car. ENDCLASS. "zcl_car_data DEFINITION
In the following class, is the definition of every prototype with the implementation of how a car should be built:
CLASS ...
Read now
Unlock full access