SRL Archive - C/C++ Help and Tutorials

How do you code?


Wrycu

2008-10-13 16:01:29

Choice 1:

if (condition)
{
//do stuff
}
Choice 2:

if (condition){
//do stuff
}

Edit:
And why?

ShowerThoughts

2008-10-13 16:06:37

I code C# it's similar I took option 1

Runescapian321

2008-10-13 16:08:07

Option 1. It's easier to read that way IMO, even if it does take up extra space.

Buckleyindahouse

2008-10-13 16:08:38

From: Runescapian
Option 1. It's easier to read that way IMO, even if it does take up extra space.

What he said an also because Visual Studio automatically formats it to that :D

Method

2008-10-13 16:14:32

I do option #2 because it looks better than option #1. I've never had problems with indenting, really, so that works for me.

Yakman

2008-10-13 18:45:07

they have names,
option1 and option2 are called Allman and K&R style respectively. (I'm fairly sure i got the right ones….)

i like K&R, simply because thats how i learnt it


i get my inspiration from this quote from a book

The position of braces is less important, although people hold passionate beliefs. We have chosen one of several popular styles. Pick a style that suits you, then use it consistently.

Bobarkinator

2008-10-13 23:35:01

I used to use Allman religiously, but I have recently switched back to K&R because it's better to code officially in my opinion. Except in SCAR lol :p. I don't follow many scar standards any more :p

Tniffoc

2008-10-14 22:56:47

For me, it depends on the language. Op #1 for C/C++ and Op #2 for Java! :D

Wrycu

2008-10-16 09:46:36

Cool. I keep seeing scripts that use option 2, and I find it really annoying.

Negaal

2008-10-17 07:04:13

1#, and this thread is stupid.

TravisV10

2008-10-17 07:23:27

I use option 2 b/c that is what is usually used with other languages I use. Plus it is easier to read because you don't make a ton of extra lines.

2 seems to be the logical way to write code.

Freddy1990

2008-10-19 10:24:35

if (condition) {
//do stuff
}

BlackThursday

2008-10-19 15:30:33

Option 1. It's how I learned to code PHP and since that's embedded in my brain now, thats probably how I'll code forever.

R0b0t1

2008-10-19 19:40:54

I make one line programs.

Harry

2008-10-19 19:42:30

You forgot

if (condition) { stuff(); }
I am all for Allman though :)

Smartzkid

2008-10-24 16:10:34

K&R all the way

Enchanted

2008-10-27 07:46:58

I personally do option 2.

#include <iostream>

int main() {
bool enchantedRules = true;

if(enchantedRules) {
std::cout << "Enchanted rules!";
}

else {
std::cout << "Enchanted does not rule!";
}

for(;;) std::cin.get();

return 0;
}

Wrycu

2008-10-27 10:10:39

From: Hy71194
You forgot

if (condition) { stuff(); }



I wasn't aware of it, but I didn't forget it! See the "other" choice in the poll?

Edit:
This thread is not stupid. It's got a purpose, and it's informative. Please keep your negative thoughts to yourself, or the flaming section.