I use tabs. I am aware that if someone has another tab-width then I have that the code can get messy.
I prefer tabs because then I only have to press backspace once instead of 4 times and I find it easier
to format with it e.g. oeps I used 3 spaces instead of four. I'm also aware that ctrl+backspace solves
my first issue with spaces but that doesn't always work like I want it to work.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
David Newton wrote:Tabs are evil. IDE/editor handles all that anyway
Handles what anyways?!
Converting tabs to spaces.
, and the headache of various alignment issues go away when you just stick with spaces.
What alignment issues?
If you use a different editor, the tabs may appear different sizes.
Four spaces per tab. I'm also at 120 chars per line, but I get twitchy when I hit 90... but wrapping at 80 in Java is a recipe for unreadability.
Why 120 characters?
Writing verbose code?
I thought 80 was the standard for nearly forever?
You can usually get a lot more than 80 columns onto a screen, but it is a good thing to have a limit as a convention, and stick to it.
120 is all right when you use an IDE or editor with no real limit to width. If, however, I am writing FORTH and have to copy-and-paste
onto a terminal with 80 columns, I occasionally get wrapping problems which the compiler misinterprets as errors if my comments are more than
80 columns wide.
There's one big advantage to tabs. I used to work very closely with another developer. I have a strong preference for 4-space indentation. He had a strong preference for 2 spaces. So we used tabs, set up our editors accordingly, and always got the view we wanted.
I usually use spaces nowadays, but you simply can't solve the above problem with spaces - tabs make it trivial.
Joined: Oct 13, 2005
Matthew Brown wrote:. . . I have a strong preference for 4-space indentation. He had a strong preference for 2 spaces. . . .
I am surprised your company didn't have a policy about tabs and spaces.
David Newton wrote:Re-format it: convert to required format on SCCS checkin/checkout, or on editor load/save, or whatever. Most dev tools can be set up to do this automatically.
It still won't handle the real issue (mixed-mode alignment), but it allows crazy 8-spaces-per-tab people to not screw up everybody else's day.
OK, I suppose I meant "how, without continually reformatting". Automating it would be OK, though.
I can see that mixing spaces and tabs is a nightmare. But the solution seems to be to use one consistently. If my colleague had been a crazy 8-spaces-per-tab person I wouldn't have even noticed, because I'd see them displayed as I want them.
That the point, though--with mixed-mode alignment you *can't* make it work correctly. Consider the various ways one can align multi-line statements. Aligning solely on tab-boundaries doesn't always provide readability; there are lots of situations where you want n-tabs + n-spaces in order to have things line up attractively (or semantically). If tab settings change that flies out the window and is impossible across environments. Reformatting can solve that problem, but it's irritating, hence spaces.
Joined: Oct 13, 2005
Matthew Brown wrote: . . . You've never worked in a University then?
We have a very strict indentation policy here at Teesside University. Everybody must have a different indentation policy from everybody else. If two people use the same indentation policy, there is a £20000000 budget cut and half the department are offered early retirement!