Skip to main content

Lightning fast commenting (in and out)

·123 words·1 min
Programming
Alejandro Duarte
Author
Alejandro Duarte
Alejandro Duarte is a Software Engineer, published author, and award winner. He currently works for MariaDB plc as a Developer Relations Engineer. Starting his coding journey at 13 with BASIC on a rudimentary black screen, Alejandro quickly transitioned to C, C++, and Java during his academic years at the National University of Colombia. Relocating first to the UK and then to Finland, Alejandro deepened his involvement in the open-source community. He’s a recognized figure in Java circles, credited with articles and videos amassing millions of views, and presentations at international events.

I have used this two or three times in my life but it’s one of those simple (and useful?) hard to forget tricks. It could be useful during tough debugging times.

If you have several lines of code and you want to comment them out, you can use standard multi-line comments (this is for C++, Java, and others):

/*
Component contentArea = getContentArea();
layout.addComponent(contentArea);
layout.setExpandRatio(contentArea, 1);
*/

Notice that you can also “comment out” the first and last lines using single-line comments:

//*
Component contentArea = getContentArea();
layout.addComponent(contentArea);
layout.setExpandRatio(contentArea, 1);
//*/

Now you can comment in and out your code just by removing or typing the first “/”:

CAUTION: Avoid usage in programmers with chronic lava flow disease, including junior and senior developers.

Related

Empty lines and semantics in source code
·537 words·3 mins
Programming
I remember a couple of years ago, while working with some developers, one of them seemed to be irritated by seeing empty lines in source code.
Enterprise App now available with Maven
·46 words·1 min
Vaadin UI News
Finally! I’ve managed to write a Maven POM for Enterprise App.
A strategy to manage large SQL tables
·396 words·2 mins
SQL Databases
Some months ago, I got involved in a project where I needed to generate quite big reports (more than 1 million rows) extracted mainly from an SQL table growing at a very fast pace.