Novicane All American 15416 Posts user info edit post |
Had a convo with CSC friend of mine. He was mentioning that a excellent programmer would write 500 lines of usable code a week.
I might write 10-50 php/sql lines a week but due to my other job duties it's just not possible for me to sit down and write that much in a week.
How much do you guys write? 8/4/2010 10:40:10 AM |
Shaggy All American 17820 Posts user info edit post |
number of lines written is irrelevent. The only thing matters is if you ship something that works on time. 8/4/2010 10:43:17 AM |
FroshKiller All American 51913 Posts user info edit post |
yeah more like an excellent programmer downloads the right library and plugs in about 50 lines to implement it 8/4/2010 10:44:19 AM |
Lokken All American 13361 Posts user info edit post |
programmers who worry about this metric aren't generally good programmers to begin with. 8/4/2010 10:49:55 AM |
Stein All American 19842 Posts user info edit post |
I probably write a line per minute.
But I also do my if statements like:
if (this){ // whatever }
I could probably put up bigger numbers if I switched to:
if (this) { // whatever } 8/4/2010 11:09:22 AM |
FroshKiller All American 51913 Posts user info edit post |
let's turn this thread into a vigorous debate about indent styles 8/4/2010 11:10:04 AM |
Shaggy All American 17820 Posts user info edit post |
Allman style or death 8/4/2010 11:10:28 AM |
Shaggy All American 17820 Posts user info edit post |
hard tabs only 8/4/2010 11:10:53 AM |
FroshKiller All American 51913 Posts user info edit post |
one true brace 8/4/2010 11:12:54 AM |
Shaggy All American 17820 Posts user info edit post |
*runs clean up on ur code and checks it back into svn w/ eclipse style prefs* 8/4/2010 11:14:17 AM |
FroshKiller All American 51913 Posts user info edit post |
i have a closing brace on this line by itself
}
and it says you're a bitch 8/4/2010 11:15:20 AM |
Shaggy All American 17820 Posts user info edit post |
if(godTierCoder) { useAllmanStyle(); }
8/4/2010 11:19:12 AM |
Stein All American 19842 Posts user info edit post |
Lets discuss ternary operators and how fun it is to embed them within print/echo statements. 8/4/2010 11:20:03 AM |
FroshKiller All American 51913 Posts user info edit post |
//if (obviouslyFucked == true) { compileWithoutReportingErrors(); }
[Edited on August 4, 2010 at 11:24 AM. Reason : well let's be accurate here]8/4/2010 11:22:20 AM |
Shaggy All American 17820 Posts user info edit post |
if i wanted to comment out a block i'd use /* 8/4/2010 11:26:40 AM |
FroshKiller All American 51913 Posts user info edit post |
who said anything about a block 8/4/2010 11:27:52 AM |
Shaggy All American 17820 Posts user info edit post |
scenario 1: want to comment out a conditional block, use /* scenario 2: want to comment out the conditional statement only, use //
Allman style scenario 1: alter 2 lines scenario 2: alter one line otb style scenatio 1: alter 2 lines, scenario 2: alter 2 lines
Allman supremacy. 8/4/2010 11:30:59 AM |
FroshKiller All American 51913 Posts user info edit post |
clearly highlighting how easy it is to mistakenly comment out the conditional statement and not realize it nub 8/4/2010 11:34:38 AM |
Shaggy All American 17820 Posts user info edit post |
if you comment out a conditional when you meant to comment out the block its you who are the scrub. Allman style is the most readable which is the only valid measure. 8/4/2010 11:36:03 AM |
FroshKiller All American 51913 Posts user info edit post |
WHO SAID ANYTHING ABOUT A BLOCK 8/4/2010 11:38:49 AM |
Shaggy All American 17820 Posts user info edit post |
if(something) { }
thats a block. If you want to comment out the block you would use /*. You would not use // to comment out a block unless you were going to comment out each line of the block which you would need to do in either style. If you meant to only comment out the conditional, then in allman style you just // the conditional. in otb you would need to comment out the conditional and the end brace or put a new brace below the commented out conditional.
tl;dr: Allman supremacy. otb go home.8/4/2010 11:41:34 AM |
FroshKiller All American 51913 Posts user info edit post |
nobody said anything about commenting out a block newbie 8/4/2010 11:41:57 AM |
Shaggy All American 17820 Posts user info edit post |
then how could you accidentally comment out the conditional? 8/4/2010 11:42:23 AM |
FroshKiller All American 51913 Posts user info edit post |
line i mean to comment out //line i accidentally comment out and don't get warned about because the braces are fine because my indent style is dumb { rest of my dumb block }
[Edited on August 4, 2010 at 11:43 AM. Reason : ...] 8/4/2010 11:43:38 AM |
Lokken All American 13361 Posts user info edit post |
or
// line i comment out because i want the code to run regardless 8/4/2010 11:44:24 AM |
Shaggy All American 17820 Posts user info edit post |
sorry for your parkinson's i guess.
Also, a true allman user would have whitespace between previous lines and the block.
[Edited on August 4, 2010 at 11:45 AM. Reason : ] 8/4/2010 11:45:31 AM |
FroshKiller All American 51913 Posts user info edit post |
Lokken please try to focus 8/4/2010 11:46:50 AM |
Lokken All American 13361 Posts user info edit post |
ur rite 8/4/2010 11:47:23 AM |
Novicane All American 15416 Posts user info edit post |
usable code is usable. 8/4/2010 11:59:59 AM |
qntmfred retired 40816 Posts user info edit post |
i use allman in .net/sql and k&r in c/php, those being the general consensus in those development communities.
can't say i've ever accidentally commented out the conditional statement alone
but then again, i'm awesome and resistant to flaws so...] 8/4/2010 12:09:17 PM |
dakota_man All American 26584 Posts user info edit post |
Allman
Sometimes I want to comment the conditional line and let its block run all the time to test something. I don't think I've ever seen somebody accidentally comment out a conditional statement.
If you want to comment out a block you should use //, most IDEs should help you out with that. The only time I use /**/ is if I'm commenting out a portion of a single line, like a function parameter's name in the definition to get rid of the YOU AIN'T USE THAT warning.
also I <3 ?: operators 8/4/2010 12:19:51 PM |
qntmfred retired 40816 Posts user info edit post |
i'm a fan of the null-coalescing operator. i think it's neat. 8/4/2010 12:21:42 PM |
dakota_man All American 26584 Posts user info edit post |
lol neat
so y = x ?? -1; is a shortcut for y = x ? x : -1;
[Edited on August 4, 2010 at 12:25 PM. Reason : me = liberty ?? death;] 8/4/2010 12:23:18 PM |
LoneSnark All American 12317 Posts user info edit post |
Visual Studio doesn't give me a choice. Wherever I put my braces, it moves them. 8/4/2010 12:57:24 PM |
kiljadn All American 44690 Posts user info edit post |
I'm a OTB user. Fuck your Allman and fuck whitespace. 8/4/2010 1:00:25 PM |
SMokE Veteran 227 Posts user info edit post |
If I'm working with code inherited from someone else, I just stick with whatever style they were using.
If I'm writing something from scratch, I usually gravitate towards the Allman style braces because it seems easier for my eyes to quickly identify blocks (especially multiply nested blocks) with the braces surround the block at the same indent level. Something to do with the symmetry, I suppose.
In any case, I don't recall ever having any issue, commenting or otherwise, where I've thought to myself "If only I had been using the other style..."
While we're talking about something that's almost entirely aesthetic, how about this one: Has anyone found a way of doing long, multi-line method/function argument lists that doesn't come out looking strange? 8/4/2010 1:26:44 PM |
FroshKiller All American 51913 Posts user info edit post |
Ask yourself why you need that many arguments and whether there's a better way to handle it (e.g. passing a single full-fledged object).
[Edited on August 4, 2010 at 1:30 PM. Reason : I AIN'T MEAN TO BE HATEFUL, IT'S JUST THE THREAD MADE ME THAT WAY] 8/4/2010 1:28:53 PM |
dakota_man All American 26584 Posts user info edit post |
This function has more pointless arguments than a tech talk phone thread. 8/4/2010 1:32:05 PM |
SMokE Veteran 227 Posts user info edit post |
Quote : | "Ask yourself why you need that many arguments and whether there's a better way to handle it (e.g. passing a single full-fledged object)." |
That's often good advice, but I'm thinking of situations like:
LongReturnTypeName LongFunctionName(LongArgumentTypeName longArgumentName,...
It really doesn't take many arguments to fill up a line that way, and I don't consider any of those names to be excessively long.8/4/2010 1:42:52 PM |
scud All American 10804 Posts user info edit post |
k&r is much more friendly to scm diffing tools I find 8/4/2010 1:47:47 PM |
Shadowrunner All American 18332 Posts user info edit post |
One true brace has a way better name, so I usually go with that. 8/4/2010 1:49:30 PM |
Shaggy All American 17820 Posts user info edit post |
I let eclipse handle the formatting for multiple arguments. I usually write them out on one line and if its crazy long i'll let the clean up handle reformating them. I have it set for arguments after a certain length to be put on the next line indented to line up with the first argument on the first line.
Most of the time when this happens its because of either long constructors for pojos or overridden/implemented methods from other libraries. 8/4/2010 1:53:47 PM |
qntmfred retired 40816 Posts user info edit post |
LongFunctionName( [tab]param1, [tab]param2, [tab]... [tab]paramn);
also, to counter frosh's point, you can't always just pass in a single object. happens a lot when doing constructor-based dependency injection. for example
public class Foo { public Foo(ILogger logger, IFooRepository fooRepository, INotificationService notificationService, IMailService mailService, IPaymentProcessor paymentProcessor) { _logger = logger; _fooRepository = fooRepository; _notificationService = notificationService; _mailService = mailService; _paymentProcessor = paymentProcessor; } }
[Edited on August 4, 2010 at 2:29 PM. Reason : poor man's DI]8/4/2010 2:22:49 PM |
Lokken All American 13361 Posts user info edit post |
to be fair
Frosh is an English major 8/4/2010 2:30:43 PM |
FroshKiller All American 51913 Posts user info edit post |
yeah that is basically one step above retard 8/4/2010 2:33:13 PM |
qntmfred retired 40816 Posts user info edit post |
well, i mean sometimes it is appropriate to encapsulate a bunch of stuff in a class and pass around an object instead
i'm just saying, that's not always the case. although to counter my own example, constructor injection can be avoided too through other dependency injection techniques or through the use of DI frameworks. 8/4/2010 2:33:45 PM |
SMokE Veteran 227 Posts user info edit post |
Quote : | "LongFunctionName( [tab]param1, [tab]param2, [tab]... [tab]paramn);" |
That's what I always end up doing, but I have also seen the way Shaggy is talking about. Having all the arguments floating out in the middle of the page looks strange to me.
The weird thing about doing it either way with Allman-style braces is that the brace following the argument list looks like it's just hanging out there on its own.8/4/2010 3:20:03 PM |
smoothcrim Universal Magnetic! 18968 Posts user info edit post |
today I wrote about 20 lines and copied another 20 from google 8/4/2010 7:19:04 PM |
Potty Mouth Suspended 571 Posts user info edit post |
A only program with graphics. 8/4/2010 7:32:18 PM |