Valhalla Legends Archive

Programming => General Programming => Topic started by: Adron on April 23, 2004, 09:48 AM

Title: Programming style and evolution
Post by: Adron on April 23, 2004, 09:48 AM
Quote from: Mephisto on April 22, 2004, 08:31 PM
I'm not trying to discourage you from learning C, but I just have to say your style is awful.  If you're going to declare a list of variables of the same type either put them into an array or declare them in one statement using the comma (,) operator.  

It is considered good style to declare no more than one variable per line, and to put a comment on that line describing what the variable will be used for.

Title: Programming style and evolution
Post by: iago on April 23, 2004, 11:04 AM
Quote from: Adron on April 23, 2004, 09:48 AM
Quote from: Mephisto on April 22, 2004, 08:31 PM
I'm not trying to discourage you from learning C, but I just have to say your style is awful.  If you're going to declare a list of variables of the same type either put them into an array or declare them in one statement using the comma (,) operator.  

It is considered good style to declare no more than one variable per line, and to put a comment on that line describing what the variable will be used for.



hmm, is the comma actually an operator here?  I know it's an operator when you do "a = 2, 3", but I don't think "int a, b" is considered the "comma operator".
Title: Programming style and evolution
Post by: Eibro on April 23, 2004, 01:38 PM
Quote from: iago on April 23, 2004, 11:04 AM
Quote from: Adron on April 23, 2004, 09:48 AM
Quote from: Mephisto on April 22, 2004, 08:31 PM
I'm not trying to discourage you from learning C, but I just have to say your style is awful.  If you're going to declare a list of variables of the same type either put them into an array or declare them in one statement using the comma (,) operator.  

It is considered good style to declare no more than one variable per line, and to put a comment on that line describing what the variable will be used for.



hmm, is the comma actually an operator here?  I know it's an operator when you do "a = 2, 3", but I don't think "int a, b" is considered the "comma operator".
No, you're right, it's not an operator when used in this context.
Title: Programming style and evolution
Post by: Adron on April 23, 2004, 06:08 PM
Btw, I don't like my old code at all. It's ugly.
Title: Programming style and evolution
Post by: iago on April 23, 2004, 07:48 PM
Quote from: Adron on April 23, 2004, 06:08 PM
Btw, I don't like my old code at all. It's ugly.

Same.  I'm embarassed with code I wrote a year ago :)
Title: Programming style and evolution
Post by: Mitosis on April 23, 2004, 08:05 PM
Quote from: iago on April 23, 2004, 07:48 PM
Quote from: Adron on April 23, 2004, 06:08 PM
Btw, I don't like my old code at all. It's ugly.

Same.  I'm embarassed with code I wrote a year ago :)

Im ashamed of my code because of people like Joker :\
Title: Re:Programming style and evolution
Post by: iago on April 24, 2004, 01:55 PM
Quote from: Mitosis on April 23, 2004, 08:05 PM
Quote from: iago on April 23, 2004, 07:48 PM
Quote from: Adron on April 23, 2004, 06:08 PM
Btw, I don't like my old code at all. It's ugly.

Same.  I'm embarassed with code I wrote a year ago :)

Im ashamed of my code because of people like Joker :\

I'm not sure what j0k3r said about your code, besides trying to give you advice about his mistakes.

The bottom line that I tell everybody I know who's learning programming:

We (that is, everybody in the world but Skywing, I think) aren't born with keyboards.  It takes time and patience.
Title: Re:Programming style and evolution
Post by: Etheran on April 24, 2004, 03:32 PM
a,b,c = 5,9,7

that's my idea of programming style :D
Title: Re:Programming style and evolution
Post by: Yoni on April 24, 2004, 03:35 PM
Quote from: Etheran on April 24, 2004, 03:32 PM
a,b,c = 5,9,7

that's my idea of programming style :D
python whore
Title: Re:Programming style and evolution
Post by: Banana fanna fo fanna on April 24, 2004, 03:39 PM
You are jealous of our eleet syntax constructs that let us write code in 1/10 the time it takes you.

Before you whine about performance, http://psyco.sf.net
Title: Re:Programming style and evolution
Post by: Yoni on April 24, 2004, 03:46 PM
Yeah, I am. I started to learn Python (hence the fact I recognized that's what Etheran wrote his line of code in) but stopped due to lack of time (I'll check again in July or so).
Title: Re:Programming style and evolution
Post by: iago on April 24, 2004, 03:51 PM
hmm

int a, b, c;

a = b = c = 3, 2, 1;


Correct me if I'm wrong, but that's valid c, isn't it?  Valid, yet horrible..

<edit>
My bad, this is what I was thinking of:

int a, b, c;
a = (b = (c = 3, 2), 1);


stupid brackets :)


Title: Re:Programming style and evolution
Post by: Banana fanna fo fanna on April 24, 2004, 04:16 PM
Yoni, you need any help, I'm pretty durned good :)
Title: Re:Programming style and evolution
Post by: Yoni on April 24, 2004, 05:01 PM
Quote from: iago on April 24, 2004, 03:51 PM
int a, b, c;
a = (b = (c = 3, 2), 1);

That's pretty nice, never thought of that.

It's pretty confusing and useless, just like good hackerish code in C should be.