|
Subject: RE: [stella] OT: Programming, CS theory From: "B. Watson" <urchlay@xxxxxxxxxxxxxxxx> Date: Thu, 25 Oct 2001 20:11:20 -0400 (EDT) |
On Thu, 25 Oct 2001, Glenn Saunders wrote:
> >>
> for(++i;i<lseek(fp)) {i+=lseek(fp+i)};
> <<
>
> I hate this crap.
>
> When I code I always go vertical.
>
> if (a)
> {
> b = 1;
> }
> else
> {
> b = 2;
> }
Well, that's apples & oranges... actually, the for loop would just give
you a parse error when you tried to compile it :)
As long as we're talking about it, I prefer this style:
if (a) {
b=1; /* I love having tab stops at 3 spaces */
} else {
b=2;
}
...still readable to me, but takes up less space vertically...
>
> I always use the brackets. I never used any sort of compacted syntax. I
> find it much more readable the long way.
>
Sometimes there's a place for that compact sytax... to me, this is readable:
b = (a ? 1 : 2); /* same as above, more compact */
...especially if you've got a lot of those tests to make, one after the other.
But I suspect it would get me yelled at, if I were writing C code as part of
a large development team. In that case, I'd make my employer spring for a
gigantic monitor, so I could run a higher resolution and fit more code on the
screen at once (yes, I'm going blind).
> I also have a style in my CF that I don't know whether it's good or bad
> practice in general CS theory, but I make a lot of use of true/false
> variables which allows me to help spread out code instead of nesting
> conditionals. Oftentimes when you heavily nest conditionals you'll have to
> duplicate code blocks (including more conditional logic with them) depending
> on the program flow. So by not duplicating the code as much the sourcecode
> gets smaller and it's easier to maintain.
I really hate having nested conditionals to the point where you're typing only on
the right-hand 10% of your editing window... at that point I start thinking of how
to break up the code into more manageable chunks (subroutines/functions/macros).
Someone with a CS degree would be more likely to decide ahead of time what functions
are required, and have the whole structure of the program worked out before writing
a single line of code... I tried to learn this style, I really did, but I guess I
have too many bad habits to unlearn. Or else there's no one `right' way to do it,
and everyone should use what works for them...
Anyway, this ramble should have a point, so let's see if there is one...
uh, I can't think of one, sorry... ptptpttptptt..
B.
-
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [stella] OT: Programming, CS th, B. Watson | Thread | RE: [stella] OT: Programming, CS th, Chris Wilkson |
| Re: [stella] OT: Programming, CS th, Greg Miller | Date | Re: [stella] Stelladoc v2 status re, YanProulx |
| Month |