Comment by mcphage

4 months ago

You know what would be great for refactoring the code? Some way to easily see what parts reference the variable you’re trying to refactor.

Unless you have spaghetti code or have built an abstraction tower, a variable is probably scoped/namespaced neatly. Often, it's just a quick grep to find it. In Emacs, if a variable is only used within a file, you can just `M-x occur` and do the editing there. Where those tools fail, is when you have ecosystems that tries to be clever (JavaScript with its transpilers, Java with its annotations)

  • Check out 'M-x multi-occur' -- same as 'occur', but scans all of the frame's open buffers. So useful I aliased it to 'M-x mo'

    • Thanks! So I learned something new about Emacs again. It never ends.

      Aliasing something to make it easier to M-x sounds like the next step after running out of letters to use with C-c? I have not reached that point yet, but that was another thing I never considered that could be useful to remember.

  • > Unless you have

    That is a big "unless". We aren't all working on pristine code written to high standards…

Yes, but not everyone uses features like this to make code easier to read. Instead, features like this make less readable code become tractible. The same can be said about autocomplete and documentation popups too. I remember Uncle Bob saying once that his 5 line function limit was facilitated by an editor feature he had that could easily display the code of functions that are called. So it stands to reason that the recommendation should be 25 lines if you don't have such a feature, I think. We don't need to go back to Hungarian notation but certainly using a bunch of fancy features to read the code makes it inherently less readable on the surface level (unless you are very anal and also self-aware and can stick to clean principles).

I'm surprised my comment was downvoted so bad for making an astute observation. It happens to me all the time. A lot of the users of this site suck.

  • And this comment will most likely be flagged now for whining about getting downvotes.

    https://news.ycombinator.com/newsguidelines.html:

    "Please don't fulminate. Please don't sneer, including at the rest of the community."

    "Please don't comment about the voting on comments. It never does any good, and it makes boring reading."

    • Lol well where else am I supposed to talk about it? I get irritated about this stuff daily, so I don't really care if my short quips bore a person here or there. Being interesting is what gets me downvoted!

      2 replies →