Thread: Formatting Standards

  1. #16
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> All companies I know have coding standards which include formatting.


    The same here. It is because a firm I was with was trying to enforce K+R that I did the research that showed Allman to be better.

    The simple truth is that most people are happiest/faster/productive with the format they are familiar with. They will do less well in an environment that forces them to use a different one. So, let all the employees use their own style but dictate a company style for archived code and supply a code formatter template which allows anyone to change to/from whatever format they like.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  2. #17
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    This is something that trips me up in Delphi as well. No brackets there, instead it uses "begin" and "end;". If there's an else, you omit the semicolon on the previous statement, even if it's an end. The default formatting starts the begin/end in the same column as the if (or whatever) statement beginning the block. If you get nested or sequences of statements within a block, it gets confusing over how many end statements and whether they need a semicolon, etc.
    The compiler catches it, but it's annoying trying to figure out how many begin/ends are matching up. Not to mention the compiler is single pass, so you have to fix one error before finding another.
    Truth is a malleable commodity - Dick Cheney

  3. #18
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    I prefer Allman also. I also like substituting spaces for tabs so they look consistent with all editors. I hate seeing posts where the indentation is 10+ spaces.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  4. #19
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    I never use tabs either. I use K&R with 2 spaces per level of indentation.

  5. #20
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    spaces are probably more superior in that respect, however it is much easier to tab twice than space 10 times (standard tab=5 spaces)
    But, it is much much quicker when an editor or ide use auto tabbing. Textpad (which i use to code for the web) has autotab but it doesn't go backwards to the previous level after } whereas visual c does. For speed of codign i prefer tabs.
    PHP and XML
    Let's talk about SAX

  6. #21
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    I prefer spaces just b/c tabs are usually too big, and of course it is not clearly defined how they are represented. Many IDEs wil automatically turn tabs into X number of spaces, but even so they usually use too many.

    Plus it is easiar to use sed scripts on spaced programs.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. question - linux - gcc - c standards
    By AMAMH in forum C Programming
    Replies: 12
    Last Post: 12-03-2009, 02:49 AM
  2. Code Standards
    By WP99 in forum C Programming
    Replies: 2
    Last Post: 08-31-2007, 04:43 PM
  3. dos game help
    By kwm32 in forum Game Programming
    Replies: 7
    Last Post: 03-28-2004, 06:28 PM
  4. Using c++ standards
    By subdene in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2002, 09:15 AM
  5. Keeping up with newest standards
    By Shadow12345 in forum C++ Programming
    Replies: 1
    Last Post: 05-04-2002, 08:06 AM