Lightning fast commenting (in and out)

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 debuging 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);
    //*/
But 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.
Programming
May 21, 2013
0

Search

Popular Posts

Building a Kubernetes cluster on Raspberry Pi (with automation)

Some months ago, I was lucky enough to get a bunch of Raspberry Pi minicompute…

How to call a Java method from a JavaScript function in the browser

In this video I demonstrate how to call a Java method that runs in the server f…

What is a Database Proxy?

A proxy is a server software, typically installed in a separate machine, that …

Recent Comments

Contact Me