35

I was checking an Arduino sketch I wrote in a hurry 2 years ago. I want to cry for the number of shit I've found there 😓
Picture + I had put as int variables that should have been boolean. I needed them for 0 and 1. As well as with no comments and no explicative names.

Comments
  • 6
    So wait... You code effectively says... If x == true then make x true if not make it false
    😂😂😂😂😂😂

    There's literally no point 😅😂
  • 3
    Reminds me of my good old Lua days
  • 1
    What's the hype with comments in the code now a days.. Only few parts of the code(logical) that's hard to understand needs commenting.. Even in my internship I was mocked for not commenting on a module which just does some basic calculations :/ You don't write a tutorial, you just write code which you ( or another programmer ) needs to understand. I have seen people write neat code that doesn't even need commenting!
  • 0
    @wolfram plus why would he need to comment... On that
  • 0
    Maybe it could be not 0 or 1, in which case

    b = (b != 1 ? 0 : b)
  • 1
    @FitzSuperUser its replacing values other than 1 to 0. Prepping for a check? But you could get away with b==1 there to.
  • 1
    @flag0 that makes sense confused the shit out of me cause I'd never do that in my life 😂
  • 0
    @wolfram The comment part was on other pieces of code, not this part specifically. It was a program done in roughly 15 minutes of free time (and little experience) featuring variables called e, q, h, f, b, and so on (that at first glance make you think "wtf is written there?").
    And I do believe that everyone wrote code like that at least once at the beginning.
  • 0
    @simonebogni why variable names are important
  • 0
    @wolfram when someone writes a slightly intricate function, I'd like to know what it does without having to decrypt whatever they wrote down. Comment your code, it's good practice.
  • 1
    @yarwest It's not.
    The name should tell you everything you need to know. If that's not possible, it probably should be split up into smaller parts.
  • 2
    The missing indentation is annoying me. 😒
  • 1
    Literate programming, guys. Literate programming.
Add Comment