Comments are essential in a developer’s life. When we work on a new feature, we often add comments that are reminders. For example:
- to validate a part of code with a colleague,
- to refactor a function,
- to fix code that is slowing down the performance,
- to split a method or a class into sections,
- to prepare the skeleton of a class and add a todo comment inside each function.
Even if you write some straightforward code, try reading it months or years later. Will it still seem simple, or would you wish you’d added comments?
4D v19 R4 takes comments to a whole new level with comment tags that enables you to better organize your comments.
There are three new tags at your disposal:
- MARK
- TODO
- FIXME
In this previous blog post, we showed you a list in the code editor, allowing you to easily navigate within your class. Comments preceded by these three tags are also displayed in this list.
You can use them within your classes or methods.
How to use them
The MARK tag allows you to split your code into sections. You can write it in three different ways. The other two tags TODO and FIXME, are written in the same way. The benefit is that they have different icons in the list, which allows you to organize your code to prioritize your future actions.
- //MARK: my comment: to add a section
- //MARK:- my comment with the line: to add a section with a separator line
- //MARK:-: to only add a separator line
- //TODO: To do this
- //FIXME: Fix this
Here is an example with an ORDA class:
The functions and comment tags are displayed in their appearing order inside the class and method. If you prefer, you can display the functions and comment tags of a class in alphabetical order by holding Cmd on macOS or Alt on Windows before you deploy the menu.
What’s Next?
Ready to step up your coding game with this new feature? Tell us what you think about this new possibility to organize your code and navigate in your classes or methods. We are waiting for you in the forum.