23
Awlex
7y

👋DON'T👋MAKE👋CONSTANTS👋IF👋YOU👋ONLY👋USE👋THEM👋ONCE👋TO👋CREATE👋ANOTHER👋CONSTANT👋

Comments
  • 1
    The compiler should neatly optimize that kind of stupidity though.....
  • 3
    Your rant sadly gave me cancer
  • 0
    Look into some kernel headers..bro..When u look into that , you may understand why it makes sense sometimes..By the way ..in those ppl use macro constants..
  • 1
    inb4 constexpr values

    Names usually just make more sense than some seemingly random number
  • 0
    Not sure why not?
    Lately I use const for everything except for loops which need to be let of course.
  • 0
    I have a bunch of those and it's completely justified. I use them as 'settings' that can't directly be used in the code so they go in another constant that is later used many times.
  • 1
    Well it depends. If you have something like

    int one = 1;
    double y = x + one;

    Then ok, it makes no sense! But if it is a sort of configurable parameter, or something like Math.Pi / 2 (I'm thinking about some trigonometric applications), then why not? It certainly improves readability!
  • 1
    @7Raiden
    More like the first case.

    Schema='https'
    Hoster='some hoster'

    Api_destination= Schema + '://' + Hoster

    (Sry about the uppercase varnames, but typing code on phone is a pain)
  • 0
    @Awlex ahahah ok that's fine then ;)
Add Comment