code-pal-for-abap icon indicating copy to clipboard operation
code-pal-for-abap copied to clipboard

Class Method called on instance

Open estevao-schultz-neto-SAP opened this issue 4 years ago • 1 comments

Such a check is known from other programming languages (Java, C# etc.), and it would be great to have it in ABAP, too: Static methods should only be called on the class (=>), NOT on an instance (->), because if someone calls a static method on an instance, they probably don't know what is really happening. (I just discovered such a case in our code which was copied a lot to other places; a check would have helped to discover this: CL_FARR_TD_UTILITY_FACTORY=>CREATE_DOUBLE( )->INJECT_ITSELF( … ) is called, but INJECT_ITSELF is a class-method.) Grassau, Joerg-Michael

Ref https://github.com/SAP/styleguides/issues/210 and https://github.com/SAP/styleguides/pull/224

lucasborin avatar Jul 12 '21 14:07 lucasborin