Code Styling. What do you prefer?

It does work though ;). I’ve seen some people use it.

Did you know that

int []primes, matrix[], threeDimMatrix[][];

equals

int primes[], matrix[][], threeDimMatrix[][][];

?

2 Likes

If you are working in Java the one on the right is correct. If you are working in most C-variants the one on the left is correct. I loathe the one on the left, but you follow the languages standards even if they aren’t what you feel is best.

I can’t tell if I am turned on or sickened by your (DarkArcana) image.

lol nope.

1 Like

The left one makes me wanna die.

if (x == y)
    x=3;

If possible.

2 Likes

why on a new line? Why not just:

if (x == y) x = 3;

The idea of disregarding standards is detrimental to the creation of good code and by extension can damage open source projects. You are free to behave like an uncultured savage in your personal code, but failure to follow even the most simplistic of standards is a good way to get your code rejected from any serious project.

Here’s some snippets of my professor’s code used in lecture:

int min = A[0];
int place = 0;
for(int k = 1; k <=10; ++k)
			{
			if(A[k] < min)
					{
					min = A[k];
					place = k;
					}
			}
}

For obvious reasons, I prefer the

for (String str : stringArray) {
    this.doThings();
}

type of bracket structure.

2 Likes

I never said people didn’t like my style ;).

Well, that’s why we have checkstyle and similar utilities, right? xD

5 Likes

I’m fine with any code style so long it doesn’t uninstall Windows (long story).

7 Likes
Do tell.
3 Likes

@DarkArcana long story short, my computer runs Ubuntu Linux.

That doesn’t explain anything, but alright.

2 Likes

I tell tomorrow. It’s late.

1 Like

Something tells me a rm -rf came into play…

2 Likes

No, but that is the best thing to do on macs.

1 Like




9 Likes

If you don’t like readability I guess that would be the wrong way then. :open_mouth: