Adding a block of comments at the beginning of a method is useful for adding a note about what a method does, as well as a list of input/output parameters. And having a few lines of human-readable text within a complicated section of code can be convenient to help you and others recall the purpose of this particular section of code. Beginning with 4D v18, your programming experience is enhanced with the addition of comment blocks!
Comments are text (notes, descriptions, reminders, etc.) in the source code, designated with special characters so they’ll be ignored by the compiler during code execution. Comments can be on a single line comment or across multiple lines. Now instead of having many lines prefixed with //, you can simply use /* at the beginning of a comment and */ at the end to comment an entire block. You can also collapse and expand them! And that’s not all, you can even add comments to any part of a line, even inside an if condition or a loop:
Why comments are important
- In a team with multiple developers working on the same project, well-commented code is helpful to others working on it so they can better understand the code and ease the process of code review/debugging.
- We’re only human and forgetting things is completely normal. If you see or edit your code later, comments can help you remember the logic you used while writing that code. Even if you write some really simple code, try reading it months or years later. Will it still seem simple, or would you wish you’d added comments?