Tag your comments, a feature by developers for developers

Automatically translated from English

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.

Vanessa Talbot

• Product Owner •

Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.

Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.