How can I use whitespaces to improve code readability

Pages: 123
@LB
Maybe because calling a large number of people idiots for simple matters of differing personal preference is fucking stupid? I didn't report him, but I agree with whoever did. I support free speech, whether I agree with what is being said or not, but there is no need for unnecessary insults (if there was, they wouldn't be unnecessary).
vlad wrote:
Programmers as other people have their own weaknesses and caprices. Idiots repeat their caprices.


You're right.

A perfect example: Some guy insulting people for having a differing opinion even after he's been reported repeatedly for it in the past. Yet he keeps doing it every opportunity he gets.

When will that guy learn? What an idiot.


Also +1 @ chrisname
Last edited on
I could present solid arguments but English is not my native langusge so it is difficult to me to write long texts. I prefer do not lose my time by explaining the next idiot who has no his own brain and repeats stupidies after other well known authorities who in fact can not write good code.

I laughed on such "solid argument" as the reference to Tornvalds. Maybe you will say that Straustrup is a good programmer? Please do not make laugh me.
Last edited on
Don't give me that crap. You know enough English to know that "stupid" and "idiot" are offensive words.

You're also smart enough to know that this is a matter of personal preference.
Last edited on
closed account (1yR4jE8b)
dis gun b gud

*gets popcorn*
@Disch

You're also smart enough to know that this is a matter of personal preference.


Disch I can not agree with you. The code representation is not a personal preference. It is not you who determines the preference. It is others who read your code determinate the preference.
For example I could like to spit everywhere. But it is not a personal preference if I am not alone.
You write code not for yourself. So your preference is not interesting to others.
Last edited on
A superficial thing like which line you put braces on certainly is a personal preference.

Maybe you're not in the modern world where an IDE can reformat code the way you specify at the touch of a button, or maybe you're too much of an idiot to have figured it out, but if I desire to view it one way, I can view it that way regardless of how it was written originally and I only have to press a button to do it.

Besides that, it is perfectly readable either way (unless you're an idiot of course.)
<Insert small opinion>
Like others have said, how you write your code largely depends on your preference, though there are common practices, like separating logically distinct code sections with an extra line. However, if you are working in a team, it would probably be best to settle on some kind of convention, so everyone in the team can better understand your code or more easily spot errors.

Things as simple as agreeing upon prefixing private, member data variables with 'm' or explicitly typing this-> whenever you call a member could make a difference.
</End small opinion>

Now back to bickering.
Disch I can not agree with you. The code representation is not a personal preference. It is not you who determines the preference.


Whether or not the author of the code is the one whose preference it is doesn't change that it's someone's preference... which makes it a personal preference.

Me? Personally I prefer to read code in the form int* ptr; because I identify the * as part of the type. I'm aware you prefer to read code formatted differently, but that's what I mean by personal preference.

Different people like different things. Just because I prefer something different from you does not make me an idiot.
closed account (3qX21hU5)
I laughed on such "solid argument" as the reference to Tornvalds. Maybe you will say that Straustrup is a good programmer? Please do not make laugh me.


Hmm what is your expectations for being a good programmer? Is it just someone that agrees with your opinions?

I'm curious, because for some reason you don't consider a person that has been the huge force in developing/implementing the code of a OS that millions use around the world. And a person that created a programming language that millions use around the world. If that doesn't make you a good programmer I don't know what will.



I don't really understand how you can call others idiots when you yourself can't recognize that coding style is a matter of preference and it varies from person to person and there is no one best style. It is like saying that the color red is the best color for a car and anyone that doesn't have a red car is a idiot.
Last edited on
I laughed on such "solid argument" as the reference to Tornvalds. Maybe you will say that Straustrup is a good programmer? Please do not make laugh me.

This interesting be would if offer could examples you some. Otherwise you're only trying to aggravate people.
@Zereo

I'm curious, because for some reason you don't consider a person that has been the huge force in developing/implementing the code of a OS that millions use around the world. And a person that created a programming language that millions use around the world. If that doesn't make you a good programmer I don't know what will.


There is nothing strange. It is the idea behind a language or the OS that is interesting to others. The code itself can be very badly written. I know programs that are used over the world however it is better do not look their code. I only wonder how such code could pass the code review.

EDIT: I am convinced that any code written with a bad style is a code with bugs. I never encountered a badly written code without bugs.
Last edited on
@cire
Maybe you're not in the modern world where an IDE can reformat code the way you specify at the touch of a button, or maybe you're too much of an idiot to have figured it out, but if I desire to view it one way, I can view it that way regardless of how it was written originally and I only have to press a button to do it.


Maybe! At least till now I do not know where there is such a wonderful button for example in MS VS for C# language.:)
Last edited on
@Disch
Personally I prefer to read code in the form int* ptr; because I identify the * as part of the type. I'm aware you prefer to read code formatted differently, but that's what I mean by personal preference.


So you write something as

for ( int* first = a, last = a + N; first != last; ++first ) { /*...*/ }

Oops! I made an error. int* is not the type of last!:) So anyone who reads this code must be careful that do not let pass the error. This requires more time to read the code.

The usual error of beginners that they follow your style and write for example

int* a[10];

while they wanted to write

int ( *a )[10];
Last edited on
On the topic of pointer/reference declarations I'm siding with Vlad, because the * and & are obviously not part of the type.

If things were otherwise, int* p1, p2; would declare too two pointers.

@ Vlad: give examples why Torvalds and Stroustrup are bad programmers.
Here, I'll even throw in a smiley face like you sometimes do. :)
Last edited on
@Catfish4

@ Vlad: give examples why Torvalds and Stroustrup are bad programmers.
Here, I'll even throw in a smiley face like you sometimes do. :)


Books of Straustrup are full of his code. It is not so rare that his code demonstrates how it should not be written.

As for Torvalds then I did not see his code. It is you who referenced to him not me. However to name Torvalds as an argument only because he (or somebody else) is well known is not serious.
closed account (3qX21hU5)
Books of Straustrup are full of his code. It is not so rare that his code demonstrates how it should not be written.


That really isn't a answer considering that "should not be written" can mean having int* p1; instead of int *p1; from your perspective.

As for Torvalds then I did not see his code.


So you laugh at Torvalds being mentioned as a good programmer and say that is no argument even though you have never looked at anything he has coded? Seems a bit odd.

It is you who referenced to him not me. However to name Torvalds as an argument only because he (or somebody else) is well known is not serious.


But it was you who said he wasn't a good programmer not us. Also usually a well known programmer doesn't get well known if he isn't good at programming...
Last edited on

@Zereo

So you laugh at Torvalds being mentioned as a good programmer and say that is no argument even though you have never looked at anything he has coded? Seems a bit odd.


I did not laugh at Torvalds. I did laugh at children arguments.
EDIT: There was a substitution of ideas. If his OS got success then it does not mean that he wrote a good code.
Last edited on
I agree with Disch, that I tend to prefer: int* a; over int *a; for the simple reason that int* is the type, versus *a which I usually reserve for dereferencing.

Vlad points out a good argument against this:
for ( int* first = a, last = a + N; first != last; ++first ) { /*...*/ }

This is a typo because first and last are not both pointers. However, the compiler does catch this and throw an error. Since I know the error message, and the line where it occurs, it's easy to fix.

We can debate which convention is better, but I think my reasons for preferring this convention have merit, and I think the arguments against this convention are not serious enough that I'm an idiot for liking this convention.

And just because Torvalds and Stroustrup may use different conventions doesn't make them idiots. "Bad programmer" is a completely different story, I have no opinion there, but certainly not idiots.

dictionary wrote:
idiot
id·i·ot [id-ee-uht] noun
a person of the lowest order in a former and discarded classification of mental retardation, having a mental age of less than three years old and an intelligence quotient under 25.
Last edited on
int * a; my preference.

int const * a, int * const b, int const * const c
Last edited on
Pages: 123