Hacker News new | ask | show | jobs
by kyranjamie 1834 days ago
These examples aren't great. Functions have names for a reason. Use them. Comments get outdated quickly, people forget/are too lazy to update them. Much less likely in my exp. that someone will not change a fn name if it's behaviour changes.

Comments should be reserved for non-obvious information. Github link, complex mathematics etc. Further, at what point does the relevance of a comment end? This ambiguity doesn't exist with a function.

    function addHorizontalScrollbar() {
      hScrollBar = new JScrollBar(scrollBar, HORIZONTAL);
      add(hScrollBar, BorderLayout.SOUTH);
    }

    function addVerticalScrollbar() {
      vScrollBar = new JScrollBar(JScrollBar.VERTICAL);
      add(vScrollBar, BorderLayout.EAST);
    }

    function initializeScrollbarCaretPositions() {
      caretX = 0;
      caretY = 0;
      caretMemX = null;
    }