Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
nicholai8938y@billgates Right, not your fault then. I'll put that right on the list of things that makes me throw up a little
-
donuts238488y
-
donuts238488y@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. -
Root825408yI'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! -
donuts238488y@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. -
donuts238488yOh and what about return Filter(GetSuperLargeDataFromDb(MakeQuery(Random.Next()))?
How do you plan to debug and terrace the logic in that? -
donuts238488yOh 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?
-
Root825408y@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. -
donuts238488y@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? -
Root825408y@billgates the point isn't not using it to debug, it's leaving it in your codebase after.
-
donuts238488y@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. -
Root825408y@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
-
donuts238488y@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 😀
How I code when I'm tired... I think I'm going to sleep....
undefined