Classes for the PROJECT
The class definition, that should be implemented in any class that maps an entity from the database, are:
METHODS:
- CONSTRUCTOR: Public – Creates the entity, without any relation to database;
- SAVE: Public – Will save the entity in database, insert or update;
- EXISTS: Public – Check if the entity exists at database level.;
- INITIALIZE: Private – Selects data from database if needed.
- *GETTERS AND SETTERS: This is a set of methods that should be implemented for every field from the entity. The methods are always GET<entity_fields> AND SET<entity_fields>, where <entity_fields> should be replaced;
ATTRIBUTES:
- KEY: Structure(TYKEY) – <entity_pks>: The primary keys of the entity;
- FOUND: Private – ABAP_BOOL – Return if the entity was found at database;
- FIELDBUFCTRL: Structure (tyFields) – SQLEXECUTED TYPE ABAP_BOOL, <entity_fields> TYPE ABAP_BOOL – Controls if the SQL was executed
- *ENTITY ATTR: Set of attributes that maps each field from entity.
This class definition creates a POCO. This is the basic for a class for THE PROJECT
According to Horst Keller, in the "ABAP Prgramming Guidelines" book, GET methods don;t make a ot of sense in ABAP.
In AAP you can have an attribute as read-only, so then a program can address it directly without the need for a "GET" method, and yet still be unable to change the value.
I can only presume you can't have a read-only attribute in Java, hence the need for a GET method.
Whenever I read someone saying "this is the rule, follow it" without any elaboration, I always start to try and work out WHY is this rule a good thing, is there a tangible benefit, or is it an "we have always done it this way" sort of thing, or a "because the manual says so" type of thing?
Hi Paul,
thanks for reading this post. In fact, we are using this rules in a project that I named THE PROJECT. The GET and the SET implements some logic to avoid database reading and to implement some kind of control when setting values, so the attributes are private and the get and set will implement logic. This is the rule for this project.