![]() |
"White space"
Who uses white space???
(if you don't know what that is, it is like making your programs easy to read) |
Re: "White space"
Why wouldn't you use white space?
|
Re: "White space"
I use it so I can read my code.
|
Re: "White space"
Quote:
|
Re: "White space"
Quote:
Generally, the argument is for how much whitespace is enough, and usually boils down to personal opinion. Personally, I like white space. |
Re: "White space"
Quote:
:p |
Re: "White space"
Quote:
|
Re: "White space"
Did anyone else think of the programming language whitespace?
After writing a bit in Python, I more fully appreciate proper formatting for code. Programming is codified communication, with the machine and with the human. I don't over kill on it in other languages, but I do try to maintain some semblance of order, even if I'm just writing a short script to check my calculations. |
Re: "White space"
I like to use white space, especially since I'm not the only one working or reading the code. Also my dad is a software engineer, and he has shared with me when he looks at code that a group is working on and they don't comment or orginize their code. Especially when others have to understand and read the code.
|
Re: "White space"
Quote:
|
Re: "White space"
I love whitespace! If the OP is trying to argue against it, he's in for a surprise if he ever gets a programming job. Even if you can read non-whitespaced code, nobody else can.
Some kids I've mentored in the past didn't use tabs at all, and it was painful to look at. It was impossible to tell, at a glance, when functions started, the scope of loops, etc. It was all either memorization or bracket-counting. |
Re: "White space"
This year I found the majority of compilation errors that I helped my students fix were due to mismatched braces (usually with inconsistent indention). Whitespace is good, especially if you want quick help.
Helpful Windriver tip: Select your code and press Ctrl-I to auto indent your code |
Re: "White space"
Quote:
|
Re: "White space"
I use it as much as possible.
I tend to follow the statement I believe Alan Anderson made: "Software is documentation that compiles into code". I my have mis-quoted that, but you get the idea. |
Re: "White space"
Quote:
|
Re: "White space"
Quote:
|
Re: "White space"
Quote:
|
Re: "White space"
Quote:
:rolleyes: |
Re: "White space"
I love white space. I do stuff like this:
Code:
function(Code:
function(int parameter1,int parameter2, ... word parameter20) |
Re: "White space"
Quote:
|
Re: "White space"
You are missing an option on that poll:
"I can't even read my own code" |
Re: "White space"
Sorry I didn't specify, adding or removing code does not change the weight!! :p
Anyways, here's some sample code from my joystick for FTC, this is how I like things whitespaced Code:
while (true) { //whitespace after an important conditional or loop |
Re: "White space"
Quote:
Now, if a line is getting too long, I will break it between parameters to for readability. And no, I haven't had anyone complain about not enough whitespace yet. The parameters for my C++ class last semester were something like 1 extra line between groups of lines (say, between 2 for loops) and 3 lines between functions, plus the comment lines. I think I had about 650+ lines for a "voting machine" program, including whitespace and comment after comment after comment--and throw in some code for good measure.:D Actually, one quote I've seen on here in the spotlights is: "A programmer's job is to write documentation that just happens to compile.", or something like that. Because it's documentation, it needs to be readable. I'd have a hard time reading the code above, due to the fact that having all the parameters separate from the header makes them look like variable declarations within the function. That's probably why they're complaining--they can't tell whether or not you're declaring variables or parameters. If you do do it this way, you might want to indicate in the comment that it's a parameter before anything else. |
Re: "White space"
Quote:
|
Re: "White space"
Quote:
Then again, you should see some of my if statements and the conditions in them... |
Re: "White space"
I would like to bring up the topic of the ternary operator. For those of you who do not know, in C you can use a?b:c; and have it as a completely valid statement so for example:
Code:
int foo(int bar) |
Re: "White space"
ternary operator=blech. The problem with it is even if you know what it does(which not everyone does), I prefer syntax that actually reflects the logic of the process(like a standard if/else)
As for whitespace--I am known among some people for writing "MLA code"--basically, I code the same way that I would right an essay, with indents, paragraphs, etc. |
Re: "White space"
Quote:
|
| All times are GMT -5. The time now is 13:55. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi