Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Michael_Keller
Active Contributor
Dear community, this week I would like to share another example with you. It's about my attempts to avoid unnecessary comments. The source code should "tell" the story ๐Ÿ™‚ Unfortunately, my source code from previous days doesn't always tell me why I wrote it. Sometimes it's really like a puzzle. It annoys me because it steals my time. So I used an example to think about how I can do this better in the future. Here is a piece from a large puzzle. It remains exciting.

<Please note that in the meantime an improved example has been published with this blog.>

In the beginning my source code looked like this.
SELECT SINGLE *
INTO @DATA(usr01)
FROM usr01
WHERE bname = @sy-uname.

In my opinion, the SELECT doesn't "tell" much. You have to pay attention to the following use of structure USR01 to recognize the context (not shown here). But I want to avoid that because it's unnecessary effort. So I reworked the SELECT statement.
SELECT SINGLE spld, spdb, spda
INTO @DATA(usr01)
FROM usr01
WHERE bname = @sy-uname.

Three fields of database table USR01 are of interest. That's helpful. However, the four-characters, technical names don't reveal much. What is the meaning of SPLD, SPDB und SPDA? If that were the $ 1 million question in a quiz show, I would have to give up ๐Ÿ™‚

Ok, next try (refactoring ... please wait ...).
SELECT SINGLE spld AS printer,
spdb AS output_immediately,
spda AS delete_from_spool
INTO @DATA(user_print_settings)
FROM usr01
WHERE bname = @sy-uname.

I was happy with my last attempt. You can see that it's about print settings. The INTO statement reveals it additionally. If you know that database table USR01 is there to store user master data, then you could imagine that it's about the user specified print settings. Who would have thought that?

I implemented the source code in a method called GET_USER_PRINT_SETTINGS. This makes it even more clear to me.

Any suggestions to make that better? I know that may seem exaggerated. But I want to create more readable and maintainable source code in the future ๐Ÿ™‚

<Please note that in the meantime an improved example has been published with this blog.>

 

Best regards, thanks for reading and please stay healthy

Michael

 


P.S.: Please support the virtual wishing well.

P.S.S.: Not tired of reading blogs? Check this blog by murbani.

26 Comments
Labels in this area