• Welcome to Valhalla Legends Archive.
 

Programming style and evolution

Started by Mitosis, April 23, 2004, 09:48 AM

Previous topic - Next topic

Adron

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.


iago

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".
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Eibro

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.
Eibro of Yeti Lovers.

Adron

Btw, I don't like my old code at all. It's ugly.

iago

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 :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Mitosis

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 :\

iago

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.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Etheran

a,b,c = 5,9,7

that's my idea of programming style :D

Yoni


Banana fanna fo fanna

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

Yoni

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).

iago

#11
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 :)


This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Banana fanna fo fanna

Yoni, you need any help, I'm pretty durned good :)

Yoni

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.