Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9164

Re: Better coding practice - "Pass by value" formal param v/s temporary local variable?

$
0
0

Option 2 has one line more and behave as expected. So it is easier to digest.

Only if you are on ABAP release > 740 with the "cool" in-line data declarations

 

I cross-checked with the ABAP online documentation & surprisingly found this discussed in detail - ABAP Keyword Documentation.

 

In fact this says & i quote -

If passing by value does not cause performance problems, that is, if small data sets are passed or sharing can be used, this method should be used for security reasons.

This more or less answers my query.

Option 1 has one line less, but I never used it. While reading the implementation, I will likely think the code is incorrect, as IMPORTING parameter cannot be changed.

Changing an IMPORTING param which was passed by reference is not allowed anyway (because of a syntax error). But i still agree it is a lil' bit confusing compared to option (2).

 

The only thing i don't like about (2) is having to create a local copy implicitly.

 

BR,

Suhas


Viewing all articles
Browse latest Browse all 9164

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>