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

What is a Database Proxy?

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

ChatGPT as a MariaDB database

ChatGPT is truly impressive. You can instruct it to do all sorts of things whe…

Building a Kubernetes cluster on Raspberry Pi (with automation)

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

Recent Comments

Contact Me