10
cygnus
2y

Lint rules that keep shouting at you unless you arrange the methods of a class in alphabetical order. What fucking value does it bring? Who fucking cares ? Why do we have them? Whhhyyyyyy ?

Comments
  • 1
    Because some people can't function unless they are dictating what everyone else should be doing.
  • 2
    OOF. It is as dumb as trying to sort CSS selectors in alphabetical order.
  • 1
    Because your code outlives your lifespan on a given project and conventions take it long way. If it is understood and accepted that things should be in alphabetical order, then complying keeps things easier for people who'll take over as they can expect the same conventions followed across the code base.
    Today it is alphabetical order, tomorrow someone would crib about camel case. Man, are we going backwards!!
  • 1
    @A4Abhiraj at the same time: how often do you have so many methods in your class that you n e e d to sort it in a known pattern just so the next guy doesn't get lost?
  • 5
    I agree with forces sorting to a certain extent (imports for example) but than also automatically fixable with a formatter.

    But not this a quality programmer knows what three better order is logically.

    I've had a colleague sort enums alphabetically with a script. Made stuff not only less readable but also broke external logger integration (guess what log LEVELS are in a order for a reason...).

    Just kill the lint rules and if they complain send them over to me.
  • 4
    @A4Abhiraj I'm all for consistency in naming conventions and all, but some rules are plain stupid and productivity killers. No sane person will try to find a method in the class by going through each one top to bottom. Ctrl+Click or good old ctrl+F is how I expect to find things in the codebase.
  • 0
    @cygnus we had the same thing in our linter. I just updated my editor to save it alphabetically. Should'nt really be a developer concern
  • 1
    Sounds like a rule you're supposed to disable
  • 4
    Enforcing alphabetical order is useless. Grouping by functionality would make sense but would also require actual AI.
  • 2
    @A4Abhiraj still @cygnus point stands. Having the order logical to it's use improves readability of the file and we don't use it for navigation like an index (because we use an index for that as functions have a variable amount off lines). Editor's can jump to things for navigation. I want my public interface in top of my class not some helper method that happens to be called ArrayReducer.

    Having a suboptimal convention is better than having no convention but having no convention is better than an undermining one.

    If you don't believe me I present you the underscore only variable names convention. First var must be named _ second var must be __ etc. Complying will be easier for future developers right?
  • 2
    @hjk101 alphabetical order is possibly (imo likely) less logical than whatever order happens naturally.
  • 1
    @electrineer That was indeed part of what I was trying to say with the better no convention thing. It's hard to create a less readable order than alphabetical.
  • 2
    When every class only has one method, it's always in alphabetical order.
  • 3
    they can shout at me all they want. constructors go first, public methods that are the main point of the class go after that, private methods related to that primary functiom go after that, and inconsequential quality of life/DRY functions go last.
  • 1
    @spongessuck when a class has no methods it adheres to any order
  • 1
    @spongessuck I like your way of thinking. If I ever encounter this I will only create classes with a conductor and do everything there. Bullshit laws should be followed to the letter not the spirit.
  • 0
    @hjk101 as an argument, what you said stands. But ofcourse what I said comes with a certain stupidity barrier. Ofcourse naming all variables with only one character _ is a stupid convention.

    How about having imports in alphabetical order ? How about a huge ass translations file in alphabetical order?
  • 0
    Point being there are cases when it certainly is valid to have this convention.

    And taking it to the extremes is definitely a wrong thing. No denying there. But my original point is if there was a set of developers who decided to follow a convention, it is for everyones benefit to follow it. Only if it is stupid like the _ thing, then get rid of it. Or like you said, alphabetical order for enums will be incorrect in almost all languages.
Add Comment