ABAP-Logger
ABAP-Logger copied to clipboard
Are the attributes in the correct place?
The logger interface has 3 attributes - as of now:
data handle type balloghndl read-only .
data db_number type balognr read-only .
data header type bal_s_log read-only .
Shouldn't they be in the class for the bl-log-class? Probably no other log class for this interface will need those attributes. What do you think?
I put them there for backwards compatibility when I introduced the factory and the interface. They were public attributes of the logger class before. And there are unit tests for zcl_logger that depend on these attributes, for example can_add_log_context. As the factory returns the interface type (and not the class type), the interface needs these public attributes. I personally haven't accessed these attributes in any of my custom code - and even if I needed them I would prefer to have getter methods. As said before I just didn't want to break any existing code...
I see, thanks for the answer. I can relate to the "not wanting to break any existing code" attitude. Maybe those could be marked as obsolete and the class should offer getter/setters. In a later stage those could be removed if need be. Jus tossing around ome ieas here.