ENHANCE YOUR CODING STYLE
Imagine yourself in a situation where you are asked to explore about a topic by just an introductory heading.Seems like judging the contents of book by merely reading its title.Difficult,isn’t it?
Same happens for a beginner like me who at the first time gets confused between a table and a workarea. It is almost impossible to sail through the oceans of Function Modules and God forbid if you get across an OOPS object, you can find yourself hitting your head against the wall.You have to understand a code(not always yours) and if your luck runs out you have to make changes to it to meet a requirement. It sometimes also happened that it made me land into a serious confusion, while trying to understand my own code which I developed a few months ago.
It was after sometime my colleague told me a secret so that no other person who works on same object faces the same fate like me. It is not a big thing but a minor thing that we all ignore or forget. It is ‘POWER OF COMMENTING’. An object, however complex it maybe, becomes easy to understand if it has been properly described in comments about it.Moreover every person has a way of coding and doing things which are not easy to understand for others. Many of us find it boring and time consuming but if a new person works on an object developed by you in future,it becomes a lot easier.
Proper commenting is a healthy practice to code. A simple comment can help you understand the reason for using a particular unknown FM or why is there a particular condition in select query. After leaving no stone unturned to understand coding,this is what I figured out about the magic of “Commenting”:
1.Increases Readability of Code
It is always easy to go through a code if you know what a particular statement does.It can help you understand the gist quickly and understand your requirement easily.
2.Increases Navigation Speed
Many times it happens you need to change a particular field or a particular part of code but it takes time to find its position in a lengthy code.Commenting makes it easier,just press Ctrl+F and search your field or module.
A new person can get confused if he/she sees a new object or even a select query he has no idea about.Proper comment,at proper places can help avoid that confusion.
So where and what should we comment.The answer is, wherever you feel this part needs some description.For example
In select queries:
To define what an include contains:
To establish relationship between displayed and technical field name:
Or to simply make the code more understandable:
It is always easier to impart your knowledge of coding to others in a systematic simple way.This also benefits others in dealing with troubles and setting benchmarks for making coding a good learning exercise.
Afterall we all are here to ‘LEARN AND DECODE’ what SAP has to offer.Aren’t we?