Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^4: My coding guidelines (utopian)

by tye (Sage)
on Apr 13, 2004 at 15:46 UTC ( #344762=note: print w/replies, xml ) Need Help??

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

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        

Replies are listed 'Best First'.
Re: Re^4: My coding guidelines (utopian)
by demerphq (Chancellor) on Apr 13, 2004 at 16:02 UTC

    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?


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

      I'm of mixed feelings with vertical alignment of things on separate lines where the lines are indented to the same level. I often won't bother but sometimes do and even (sometimes reluctantly) admit that such can make the code easier to read, though I find that it can clearly be taken too far. For example, lining up punctuation just boggles me even though I've seen code like this:

      my $i = 1 ; my $maxPercentDebit = 100.0+($i/100.0); $i = int ( $i ); $maxPercentDebit = normalizePercentage( $maxPercentDebit );

      But I really hate lining up indentation of a line to match the length of code on a previous line. So I'll often rewrite code such as:

      $maxPercentDebit = normalizePercentage( $i, $maxPercentDebit );

      to something more like

      $maxPercentDebit = normalizePercentage( $i, $maxPercentDebit );

      (especially assuming a much longer list of arguments such that it doesn't make sense to group the arguments into a single line).

      I even prefer to treat () more like {} and write:

      $maxPercentDebit = normalizePercentage( $i, $maxPercentDebit, );

      and in C where the extra trailing comma isn't tollerated, I'd really like to use:

      maxPercentDebit = normalizePercentage( i , maxPercentDebit );

      but hold no hope of getting any of my current cow orkers to see the beauty in that. (:

      - tye        

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://344762]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2021-02-25 05:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found