http://qs321.pair.com?node_id=216147


in reply to Re: My coding guidelines
in thread My coding guidelines

Ok. In the sense of an RFC "SHOULD" is more appropriate.

Tabs give me the possibility to indent code as I prefer it (Tab=4 Spaces) without forcing anyone to view it exactly the same way. People use indentation from 1 to 8 columns, why should i have to force anybody to like 4?

And about the 80-character width: You'll need a 48 character statement on a line after 4 8-Space-Tabs to hit 80 characters. For two reasons this cannot/should not happen: You should always break lines after about 30 characters for readability AND indentation deeper than 4 levels should indicate that a subroutine to split up the nested logic is needed.

--
http://fruiture.de

Replies are listed 'Best First'.
Re: Re: Re: My coding guidelines
by demerphq (Chancellor) on Apr 13, 2004 at 15:18 UTC

    Tabs give me the possibility to indent code as I prefer it (Tab=4 Spaces) without forcing anyone to view it exactly the same way.

    IMO your argument is faulty. If you code with tabs set to non standard width then odds are your code will look totally wrong on someone elses screen. And vice versa. Code written where the indent is 4 spaces but the editor autoconverts 8 spaces to a tab is going to look wonderfully screwed.

    IMO the only sane way to indent code is with spaces. There is no ambiguity about how the code should look when its displayed then.


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi


      In a perfect world, most editors would support the concept of only using tabs for indenting and never using tabs elsewhere (in such a configuration, all lines would match /^\t*(?!\s)[^\t]*$/, no matter what the user typed, perhaps even relaxing the (?!\s) part if they trusted the user to not abuse the privilege).

      In such a world, coders could choose this configuration and only ever indent code by an integer number of tabs and then the level of indentation could be adjusted on a whim (by changing the tab size) with reasonable results.

      The other requirement is that such coders would need to not attempt to vertically line up parts of lines unless those lines are indented to the same depth. I find such attempts to be very annoying anyway, so I don't consider this a big hurdle. Even Code Complete notes how evil such practices are.

      So all we need is wide support for this idea from editors. Unfortunately, I have yet to find even a single editor that supports such a configuration. Otherwise, I'd probably advocate it myself.

      As things stand, I find that 4-space indenting is acceptable to nearly everyone and so just standardize on that.

      - tye        

        I find such attempts to be very annoying anyway, so I don't consider this a big hurdle. Even Code Complete notes how evil such practices are.

        Ive read what code complete has to say on this, and I wont argue against the view this is bad. But personally I find that I use such reorganization as a comfortable place to do something mindless with the code while meditating on the code. Ive noticed that when i am very clear on what I want to do and what the code already does I dont bother with such things, but when the code is new, or the ideas fresh I spend endless amounts of time realigning things. And I dont consider it time wasted.

        Out of curiousity does your dislike of this stems from writing code such that it does line up or from reading code which already does? I ask partially because most of my patches here have some form of internal vertical alignment in them, and I wonder if it really puts you off so much?


        ---
        demerphq

          First they ignore you, then they laugh at you, then they fight you, then you win.
          -- Gandhi