Mine is that the useState hook is an actual plague on the entire React ecosystem. Regardless of your opinions of React, if you wanna use something then use it right.

  • jason@discuss.online
    link
    fedilink
    English
    arrow-up
    27
    arrow-down
    2
    ·
    22 小时前

    OOP dogma isn’t just bad, it’s actively harmful. OOP leads to unnecessary boilerplate. Any boilerplate that is not absolutely necessary is noise and bad. Full stop.

    Private (Getters/setters): Strictly not a necessity in any sense of the word.

    Short functions everywhere.

    Short files everywhere.

    I prefer to see the steps of execution that are actually happening in the real world on hardware. Not an ivory tower of code that happens to execute.

    • Dr. Moose@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      9 小时前

      This is just not true. Not only OOP “boilerplate” improves human comrepehension and maintainability it also improves AI ability.

    • danhab99@programming.devOP
      link
      fedilink
      arrow-up
      2
      ·
      14 小时前

      A bunch of weeks ago the CTO of my company calls me up to ask about my prejudice against the useState hook, I’m guessing I’ve just been giving my team too much shit in code reviews about them using useState hooks and they went to complain to him and he asked me to explain what the value of the useReducer hook was.

      His background is Java, Microsoft Java, C++, and not much else.

      So I was able to explain to him the value of the useReducer hook is a lot like the common class object. In useReducer you’re expected to write discreet state mutations and the state could potentially have more than 1 primitive field that gets mutated, and that’s just what object classes are! In an object class you’re writing methods for mutating the underlying state, the reason I think most people don’t feel like these two things are the same is because of the functional appearance of the reducer function and how in object classes you have the this as a variable just like any other, so you’re not returning a new state.

      So just like in react where they’re installing REDUX (like three generations of their families would be massacred if they didn’t) just to write a switch case statement that puts the action in variables in the state. Bad programmers are just bad.

    • leMe@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      2
      ·
      19 小时前

      generally agree, probably most devs nowadays do. otherwise there wouldn’t be stuff like @data in lombok.

      i think the word ‘dogma’ is pretty good: it takes a good idea (encapsulation) too far. i am not old enough to have been coding when OOP was the new and hot stuff. but i imagine it comes from the idea that it is a good idea to protect private members where needed.

      public class Account {
        private Integer balance;
        public Integer getBalance() {
          return new Integer(balance);
        }
      }
      

      that is not such a bad idea to protect balance from stupid sideeffects.

        public String getName() {
          return name;
        }
      

      is a nothing burger, as it returns the same reference and does not protect from accidental sideeffects.