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

Re: My coding guidelines

by Abigail-II (Bishop)
on Nov 27, 2002 at 18:16 UTC ( #216140=note: print w/ replies, xml ) Need Help??


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

As I said in the article, these are my rules, and I don't enforce them on anyone (I don't work with people who need other peoples guidelines - and usually I don't work with anyone). It's my code that needs to adhere to the given guidelines.

Furthermore, I was using SHOULD and MUST in the same sence RFCs use them (that's why they are capitalized). MUST means MUST. It doesn't mean "most of the time, but there are exceptions". That's what SHOULD means. MUST means the rule should be followed always. SHOULD means the rule should be followed usually, but there might be exceptions.

You don't want to discuss tabs, but I'm interested why your preference for tabs. What do tabs give you that spaces don't give you?

Abigail


Comment on Re: My coding guidelines
Re^4: My coding guidelines
by Aristotle (Chancellor) on Nov 27, 2002 at 18:22 UTC

    The reason I like tabs is because of metainformation - one tab = one level of indentation. I use tabs only at the beginning of the line and only to indent. If I need to vertically align, say, the fat commas in a hash assignment, I use spaces; even if for some reason I wanted to right-align said hash keys I would indent them with tabs then add spaces in front of the keys.

    That way, so long as you don't vertically align things on lines across different levels of indentation (and if you want to do that, something is probably wrong), everything will always line up regardless of the reader's tabwidth setting.

    (See Re: download progress with gtk for an example of how I indent.)

    Makeshifts last the longest.

      But if you use spaces instead of tabs, indentation will also align. And you don't run the risk lines will be pushed over the 80 char limit if someone uses different tab settings.

      Abigail

        But if you use spaces instead of tabs, indentation will also align. And you don't run the risk lines will be pushed over the 80 char limit if someone uses different tab settings.
        But using spaces you are forcing the others to use for indentation the same number of spaces you've chosen, while they may prefer to use different settings.

        Think for example of a visually impaired person (or simply a tired night coder) who wants 8-spaces indentation, who deliberately sets her tabs that way, to obtain what she wants regardless of the indentation habits of her colleagues (and still preserving their freedom to nest as deep as they prefer).

        By using spaces for indentation, as you suggest, your are forcing her to use your own indentation settings (which could be even a single space for that matter), which is not kind at all. Furthermore, any decent editor permit you to (automatically) convert tabs to spaces (the amount of them you prefer), while the opposite is not (always) true.

        In a word, tabs are portable, while spaces aren't (so tabs are not evil ;-)

        Ciao,
        Emanuele.

dupe
by NodeReaper (Curate) on Nov 27, 2002 at 18:24 UTC

    Reason: Aristotle please delete

    For more information on this node visit: this

Re: Re: My coding guidelines
by fruiture (Curate) on Nov 27, 2002 at 18:35 UTC

    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

      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        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-09-01 19:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (17 votes), past polls