News for hackers. Stuff that matters.
Re:Useful and useless code comments by juloo on Friday June 18, 2021 @09:12AM (#27549909)
I always try to write a comment that say "why" the following code is needed or what concept it implements rather than what it does in details.

I would do

    // We allow scrolling in two directions
    hScrollBar = new JScrollBar(scrollBar, HORIZONTAL);
    add(hScrollBar, BorderLayout.SOUTH);
    vScrollBar = new JScrollBar(JScrollBar.VERTICAL);
    add(vScrollBar, BorderLayout.EAST);
    caretX = 0;
    caretY = 0;
    caretMemX = null;
(I don't have much inspiration in this specific example)

There are no comments on this comment yet.