7
donuts
7y

How I code when I'm tired... I think I'm going to sleep....

Comments
  • 2
    I'm triggered by inconsistent use of single and double quotes.
  • 1
    don't do that curly braces 🙅🏾‍♂️
  • 1
    @nicholai uh this is C#... Join needs string, Split needs char
  • 2
    @billgates Right, not your fault then. I'll put that right on the list of things that makes me throw up a little
  • 1
    @gedankennebel no braces == syntax error, this ain't Python.

    My point was those abbreviations.
  • 2
    @billgates sorry I meant that line break for curly braces 😳
  • 1
    I'm pretty sure there is a hell's circle for PascalCase coders like you.
  • 0
    @LagunaRock and thus the code wars begin... Again...

    I guess there is... If this were Java's Hell... But that Hell is very large, in fact so large, people rebelled and created Scala.
  • 2
    I'm assuming from the override that this is part of a class, so that's fine. (However, if it's not and you're overriding the default ToString for everything, you need to die.)

    But what's with declaring variables just to return them? Bad! Hissss!
  • 0
    @Ashkin oh you can answer the question I've always had!

    I see this in Sonar all the time... So my question why is it bad?

    I know often I want to break point to inspect the object created.. before it's returned so I can also get the callstack.
  • 0
    Oh and what about return Filter(GetSuperLargeDataFromDb(MakeQuery(Random.Next()))?

    How do you plan to debug and terrace the logic in that?
  • 0
    Oh n live editing, returning some logic but I don't want to wait 20 minutes every time I need to rerun one of the functions but I need to figure out which of the functions is causing the bug?
  • 2
    @billgates While it's definitely useful for debugging, it's bad form. The issue is that you're declaring a var (and therefore memory) for something that is only referenced once. A good compiler will optimize that useless var into oblivion, so there isn't really a reason not to do this... there just isn't a reason to do it, either. (Excluding poor compilers, VB(?), and some interpreted languages who will allocate the memory anyway)

    However, it looks like an oversight, and slightly complicates reading your code, so I see it as a styling error.
  • 1
    @Ashkin ok but that's just a reference pointer, so that's 16bytes? So 16bytes/8GB+ RAM vs many minutes saved while debugging (or if I decide I actually want to use the object?).

    Also as you said, compiler will optimize anyway.

    Anyway not trying to pick a fight but never really understood why... I guess it only matters if you call a method 10000 times and need it optimized so the whole thing completes in a second, similar to the cost of catching exceptions? Or if your programming in an env. with very very limited memory?
  • 1
    @billgates the point isn't not using it to debug, it's leaving it in your codebase after.
  • 0
    @Ashkin ahh, ok but what about code readability?

    For my extreme example, and I guess with FP which is basically this rule applied to everything (to me clojure code is unreadable...)

    Yes you can write a whole app in one line but no one but you can really understand it unless they really try and spend a few hours understanding what you did and why.
  • 1
    @billgates when you see a return, you don't have to look anywhere else, but when you see a var declaration, you want to see where else it is used. This is why it slightly reduces readily
  • 1
    @Ashkin hm... But let's say I put those Converts directly into the constructor. Isn't that even less readable?

    Now you would have to lookup the args to figure out what they are **ahem... JS** and if I changed the constructor and added another param...

    Guess I should prolly ask your in Quora instead though... Thanks 😀
Add Comment