Monday, December 11, 2017

Chained Methods and Method Chaining

Method chaining has been available for last few ABAP releases. This is applicable only for functional method calls. e.g. meth1( )->meth2( )->meth3( ).

Chained statement using colon operator is also available since long long time. e.g. data: a , b , c.

The programming guideline states some incorrect ways of chaining which pass syntax check but do not increase readability.

Recently I came across a standard code that was chaining method calls to make code readable just like macros.

Example:

meth1( p1 = 'A' p2 = :

'This' ) ,

'Is' ) ,

'It' ).

Such creativity is applicable only when last actual parameter differs and rest of the method call remains unchanged.

No comments: