AamirM: there's much more than indentation than can annoy. Where do braces go, how to comment, how to line up function parameters, how to write declarations, etc. Honestly the programmer should adapt to the coding style used in the project, period. And even then, IDEs now provide tools to reformat the entire code as you wish. Use that if you're so anal about it.
This too. Bear in mind that if you're not the only person working on a piece of code, you should (as a group) define a style, and make sure everyone sticks to it. Code in a style that isn't yours is better than code in four different styles.
You should always get in the habit of indenting no matter what language you're using, it makes your code vaguely readable no matter how bad it is if the indenting is right. I work in Python now so indenting is mandatory but I was doing this as far back as VB a decade ago =P
If it were ONLY hard tabs, I could live with it. Unfortunately, the majority of brain-dead editors today mix hard tabs with spaces. In your example of a tab size of 2 spaces, your typical editor will still have a hard tab of 8 and will insert 2, 4, or 6 space, then replace eight with a hard tab, then give a hard tab + 2, 4, or 6 spaces, then 2 hard tabs... Also, allowing a person to choose the indentation via hard tabs can make the formatting outrageous - for example, instead of 2 as you mentioned, this person uses a tab of 12... and when combined with a project made with tabs of 2, you wind up with a project that's 1000 characters wide because all 2 space tabs are now 12 wide. I run into this all the time, so often the first thing I wind up doing is a global search-and-replace on hard tabs with spaces.
If one were to change tabs from perhaps 8 to 4 it is still quite likely everything will look completely mangled up, especially in case of ASM. I don't indent my code mostly, only when there's some confusing algos going on... Here's some crappy code, Nineko may like it : Code (Text): FOR x% = 0 TO XLENGHT% STEP 8 TILE$ = "": TILE1$ = "": TILE2$ = "" FOR y% = 0 TO 15 SELECT CASE EIGHTBITMODE% CASE 1 FOR I% = 0 TO 7 STEP 2 IF PIXELS%(y%, x% + 0 + I%) > 15 THEN PIXELS%(y%, x% + 0 + I%) = 0 IF PIXELS%(y%, x% + 1 + I%) > 15 THEN PIXELS%(y%, x% + 1 + I%) = 0 TILE$ = TILE$ + CHR$((PIXELS%(y%, x% + 1 + I%) AND 15) OR (((PIXELS%(y%, x% + 0 + I%) - 16) AND 15) * 16)) NEXT I% CASE 2 FOR I% = 0 TO 7 STEP 2 IF PIXELS%(y%, x% + 0 + I%) < 16 THEN PIXELS%(y%, x% + 0 + I%) = 0 IF PIXELS%(y%, x% + 1 + I%) < 16 THEN PIXELS%(y%, x% + 1 + I%) = 0 TILE$ = TILE$ + CHR$((PIXELS%(y%, x% + 1 + I%) AND 15) OR (((PIXELS%(y%, x% + 0 + I%) - 16) AND 15) * 16)) NEXT I% CASE 3 FOR I% = 0 TO 7 STEP 2 A% = PIXELS%(y%, x% + I% + 0) IF A% > 15 THEN A2% = ((A% - 16) AND 15) * 16: A1% = 0: ELSE A1% = (A% AND 15) * 16: A2% = 0 B% = PIXELS%(y%, x% + I% + 1) IF B% > 15 THEN B2% = ((B% - 16) AND 15): B1% = 0: ELSE B1% = (B% AND 15): B2% = 0 TILE1$ = TILE1$ + CHR$(A1% OR B1%) TILE2$ = TILE2$ + CHR$(A2% OR B2%) NEXT I% CASE ELSE TILE$ = TILE$ + CHR$((PIXELS%(y%, x% + 1) AND 15) OR ((PIXELS%(y%, x% + 0) AND 15) * 16)) TILE$ = TILE$ + CHR$((PIXELS%(y%, x% + 3) AND 15) OR ((PIXELS%(y%, x% + 2) AND 15) * 16)) TILE$ = TILE$ + CHR$((PIXELS%(y%, x% + 5) AND 15) OR ((PIXELS%(y%, x% + 4) AND 15) * 16)) TILE$ = TILE$ + CHR$((PIXELS%(y%, x% + 7) AND 15) OR ((PIXELS%(y%, x% + 6) AND 15) * 16)) END SELECT
I do Have some VB5 code now: Code (Text): Private Sub Command2_Click() Open Label1.Caption + "\" + Text1.Text For Binary As #1 For I% = 0 To 1023 a$ = Chr$(Stage(I%)) Put #1, , a$ Next I% For I% = 0 To 3 If Option4(I%).Value Then Exit For Next I% 'direction a$ = Chr$(I% * 64) Put #1, , a$ a$ = Chr$(0) Put #1, , a$ 'x a$ = Chr$(List1.ListIndex) Put #1, , a$ a$ = Chr$(0) Put #1, , a$ 'y a$ = Chr$(List2.ListIndex) Put #1, , a$ a$ = Chr$(0) Put #1, , a$ 'perfect a$ = Chr$(List3.ListIndex \ 256) Put #1, , a$ a$ = Chr$(List3.ListIndex And 255) Put #1, , a$ Close #1 If File1.ListIndex = -1 Then File1.Refresh End Sub
I know: 68k ASM C, Java, I won't claim to know C++ cause I use it so rarely I forget how to do shit QB, VBC, VB.NET (I haven't used those three in ages) Python PHP, MySQL (does that one even count?) XHTML, CSS, JS GML (Game Maker), AHK (AutoHotkey) And yes I did actually program something interactive in AHK, it's an anime episode chooser I use in the lounge (Essentially the media center PC except it's not running Media Center, it's running ordinary Windows XP). I kind of wish there was a C-style version of AHK, because AHK is incredibly useful but the syntax is even more horrendous than Basic. Use tabs. Just... use tabs. For the reason already stated in the thread - anyone reading the code will see it with their preference of tab width. Also, it only takes one keystroke to backspace a tab, while it takes eight (or four if you're not hardcore) keystrokes to backspace an indentation of spaces. Code (Text): void main(void) { <tab>... } Do that, it looks so much neater. If you put it on its own line, the shape of the lines moves to the left for the one-character brace which is aligned with the start of the line it should be on... and then moves back over to the right for the body. If you put it where it should be, the shape of the line moves right for an indent... as it should. I've also seen people doing this: Code (Text): void main(void) <tab>{ <tab>... } which is just plain wrong, the brace is not part of the body.
Pretty much all modern IDEs and text editors will kill space-based indentation in a single stroke, so that reason is out of the way. And like it has been said, usually hard tabs end up mixed with spaces, making the indentation look completely wrong...
Thats the format im trying to use now. I actually got marked down in a technical interview for using the following format: Code (Text): void main(void) { <tab>... } Apparently senior developers don't like it...
Objective-C , please don't hit me. :P Nah, actually C++, but I'm learning/interested in learning Objective-C.
What has indentation has to do with "technical" interview? It's a matter of preference and style (unless you were given some standard/guidelines to adhere to). It's like a bunch of these senior developers (aka fags) would mark you down if you liked Coke instead of Pepsi. I want to punch these sort of interviewers.
That only works for tabs at the beginning of a line. When tabs are used in the middle of a line, that's where it screws up (like in the disassemblies we have, some people use an editor configured for 4-space-wide tabs and they start putting 2 tabs after short mnemonics like jsr, not knowing they should be using 8-space-wide tabs). The only way to solve code style issues is to use a programming "language" that isn't plain text, but encoded in binary or something (an abstract syntax tree, what). An editor could show the code in whatever style you like, but that information wouldn't be part of the code itself. The downside of this is that a custom editor would be required to edit the code, you can't just use any text editor out there.
Absolutely nothing is the answer. But it goes to show how far some people wil go to get the perfect candidate. Its understandable if indentation and bracket use was inconsistent but it was just because their team didnt like the style I was using as it meant they would have to "change the way they read code".
That's not VB, that's old-style BASIC being forced though VB5. =P VB5/6 native code is more like: Code (Text): Private Sub sonic_write_Click() Open RomPath For Binary As #1 For Counter = sonic.LBound To sonic.UBound With sonic(Counter) If Len(.Text) < .MaxLength Then .Text = .Text & String(.MaxLength - Len(.Text), 32) '32 is the character code for space WriteString 1, .Tag, .Text End With Next Counter Close #1 MsgBox "Writing complete!", vbInformation, "Sonic Text Editor" End Sub =P