Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In reading another programmers code, he uses a format I have never seen. E.G.

    namespace MyNs.HereWeAre
         {//tab here for some reason
         public class SomeClass
               {//here's another tab
               public string Method()
                    {//yet another tab
                    string _variable = "";//no tab implementation
                    return _variable;
                    }
               }//eof - class  (Yes these eof comments are on every file)
        }//eof - namespace
// eof - file

I'll admit...this code makes me angry. It is difficult to achieve this style. One needs to fight the default formatting provided by the IDE, visual studio.

I could swallow this pill a little easier if I knew that there was a good reason for this style. Does this style stem from some other programming language/IDE?

share|improve this question
5  
That is just bizarre. In my 18 years of development, I've never seen that convention. –  17 of 26 May 15 '12 at 15:31
5  
If I had to guess, I'd say the programmer is a Python convert who is mildly upset at needing braces at all and is used to indenting all sub-tokens of syntax. –  Telastyn May 15 '12 at 15:35
20  
CTRL K + CTRL D ! –  RYFN May 15 '12 at 15:36
2  
@Zeus - Oh my gosh that is going to save me so much time resolving this unconventional formatting!! You should get some answer points for that. –  P.Brian.Mackey May 15 '12 at 15:41
1  
That reformatting shortcut (Ctrl K + Ctrl D) also works on HTML files and other formats in Visual Studio. –  Oded May 15 '12 at 15:44

2 Answers 2

up vote 19 down vote accepted

Yes: http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style

The Whitesmiths style, also called Wishart style to a lesser extent, is less common today... It was originally used in the documentation for the first commercial C compiler, the Whitesmiths Compiler. It was also popular in the early days of Windows, since it was used in three influential Windows programming books, Programmer's Guide to Windows by Durant, Carlson & Yao, Programming Windows by Petzold, and Windows 3.0 Power Programming Techniques by Norton & Yao...

This style puts the brace associated with a control statement on the next line, indented. Statements within the braces are indented to the same level as the braces...

The advantages of this style are similar to those of the Allman style in that blocks are clearly set apart from control statements. However with Whitesmiths style, the block is still visually connected to its control statement instead of looking like an unrelated block of code surrounded by whitespace. Another advantage is that the alignment of the braces with the block emphasizes the fact that the entire block is conceptually (as well as programmatically) a single compound statement. Furthermore, indenting the braces emphasizes that they are subordinate to the control statement.

A suggested disadvantage of this style is that the ending brace no longer lines up with the statement it conceptually belongs to. However, the closing brace belongs to the opening brace and not to the control statement...

It's one I've never seen practiced though, thank IPU.

Eclipse has a built in Whitesmith code style for c++...you might be screwed with Java since everyone is supposed to use the same style in that language.

share|improve this answer
4  
oh um what does "thank IPU" mean? Google won't tell me... –  sparkleshy May 15 '12 at 16:39
4  
Invisible Pink Unicorn. en.wikipedia.org/wiki/Invisible_Pink_Unicorn –  Scott Wilson May 15 '12 at 17:12
    
Whitesmiths style doesn't include tabs at the end of a line. Tabs anywhere except at the very beginning of a line are evil and need to be killed with fire. –  tdammers May 15 '12 at 21:29

Whilst your colleague's coding style is bizarre, ugly and hard to read:

  1. if you don't have coding standards, then their formatting is as valid as any.

  2. if you reformat their code every time you touch a file written by them, you'll find it very difficult to track changes - if you perform a diff using your VCS, then many if not all lines of code will have changed.

This is why you should have coding standards, it makes it easier for everyone to know what they should be doing and easier to justify reformatting if they haven't stuck to it.

If they still work at your company, have you tried talking to them about it?

share|improve this answer
    
This person is long gone b4 my time. Now, we go by microsoft framework design guidelines. –  P.Brian.Mackey May 15 '12 at 17:15
9  
In that case, I recommend checking in the code reformat as a separate check-in (e.g., Ctrl K + Ctrl D) before making changes (to make that specific change easier to track). –  Brian May 15 '12 at 20:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.