TAW_12 Chapter 9, OO design patterns Flashcards
An ABSTRACT class or method has definition and implementation cannot be…
Instantiated
Can a Static method be abstarct?
No, static methods cannot be redefined
Both Classes and Methods can be _____ to prevent redefinition or inheritance
FINAL
Can an ABSTRACT class be FINAL
Yes, but it should only contain static components
How can a table of references be read using their public attributes?
table_line->fld = fld2
SAP recommends limiting public attributes to what?
Read-only mode
What does the addition table_line provide
Access to public attributes of the internal table object reference
In the statement lcl_class = NEW what can be?
Either the super or subclass of the ref defined in the data statement
Check this out!
data lcl_alv type ref to cl_gui_alv_grid.
lcl_alv = NEW #( i_parent = NEW cl_gui_custom_contatiner( conatiner_name = ‘CONTAINER_1’ ) )
Whoa! objects on the fly!!
IS INSTANCE OF
Will determine if the object is type of the class or its subclasses
CASE TYPE OF doe what?
Checks if the object is of a class type. The when can be combined with an into CASE TYPE OF CL_CAR. When type cl_suv INTO lcl_suv
Where does CREATE PRIVATE get declared and what does it mean?
At the Class Definition. It means an object can only be created within the class itself. Usually in a private static method of the class.
What are the advantages of a factory method
It can handle a lot of coding (locks, auth checks, prereq code) without burdening the programmer Multiple factory methods can exist for one class A factory method can choose to implement a suitable subclass if needed A factory method can be managed by the class itself to prevent duplication (a group of singleton)
One way to create a singleton is
Create PRIVATE public section class-method get_instance returning value(the_instance) private section data: keep_instance type ref to this_class) method get_instance if the_instance is initial. keep_instance = new #(this_class). endif. this_instance = keep_instance
When a class declares a friendship, does it automatically become friends with the friend’s friends?
No