ID:1265750
 

Poll: Is it worth the trouble to condense your codes?

Yes 38% (8)
No 61% (13)

Login to vote.

What's up, BYOND!

I personally don't like to condense my codes because the readability of it goes down and I tend to have a hard time pinpointing bugs, etc.

Feel free to write the reason why you do or don't condense your code!
It depends.
//  Don't condense something like this
if(a)
b = c
do_stuff()
blah_blah()

// into this
if(a){b=c;do_stuff();blah_blah()}

// Do condense stuff like this
if(a == 1)
b = 1
else if(a == 2)
b = 2
else if(a == 3)
b = 3

// into this
b = a


// Basically, don't copy/paste when you can just use a proc or a formula.
// But inside those basic algorithms, no condensing should be necessary.
It's all about preference.
If we're talking purely stylistically, I dunno why you would. It seems in most regards counter-productive, for the reasons you've stated. Harms readability, makes maintenance and debugging a bit trickier because of it, etc.
When we talk condensing, are we talking,

mob
proc
ProcName(arg1)
if(arg1)
//do stuff
return
// Skipping the else
// do stuff
return

// or

mob
proc
ProcName(arg1)
if(arg1) // stuff
else // Other stuff
Kaiochao pretty much hit the nail on the head with his examples, thanks. I was also told that some people condense for shorter compile times? Is there any truth to this?
In response to Chickenlegs
Not really, no. Condensing your code almost never matters in languages that gets compiled down to machine/byte-code and thrown in a binary. The only time condensing especially matters (though you'd use a tool to do this during deployment, rather than condensing it as you write it) is in the case of web programming, such as JavaScript. Helps cut down on page load times and bandwidth usage.
Alright then, thanks for all of your inputs! :-)
I condense my code once I've actually finished tinkering with it. Other than that, while I'm debugging and working on it, I keep everything nice and spaced out. I honestly don't mind if I do have to pick back through condensed code, however. I can read it just fine because I keep my code well documented and know what's going on where.
Why do you do that?
Personal preference. It might not be logical to you, but it works wonderfully for me.
Well no, quite. It's also not logical to the software community at large though, which is a bit more concerning perhaps.
I was meaning particularly for DM, though. When working with C++, I stick with a more standard format.
Got an example of what you mean by 'condense' for DM, out of curiosity? Maybe what I'm thinking, and what you're doing, are two quite different things. P:
getTarget()
set hidden=1
var/active/zombie/closest
for(var/active/zombie/z in ohearers(8))
if(!closest)
closest=z
continue
if(dist(z)<dist(closest))
closest=z
setTarget(closest)
cycleTargets()
set hidden=1
if(!target)
for(var/active/zombie/z in ohearers(8))
setTarget(z)
return
var/found=0
for(var/active/zombie/z in ohearers(8))
if(found)
setTarget(z)
return
if(z==target)
found=1
continue
setTarget(null)


Basically I just mean removing all of the white space.
Oh. Dunno why you'd do that per-say ... what is the benefit, to you?
OCD.
Ah well, mental disorders are a whole issue of their own. P:
In response to Solomn Architect
If you really wanted all whitespace gone, you'd use a slash after "set" instead of a space, and not use newlines or indentation (which is off in your code, by the way).
That's because when I copied it, I wasn't paying attention to correcting the indentation. It's perfectly fine in the actual source file. I haven't worked on it in some months, however.
Page: 1 2