Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Re: My coding guidelines

by fruiture (Curate)
on Nov 27, 2002 at 17:25 UTC ( #216124=note: print w/replies, xml ) Need Help??

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

No, this is a misunderstanding: The rule says "you must", because it doesn't want to leave any doubts to somebody who doesn't know enough to break it with sense. I know that if i want to mess around in some symbol tables (e.g. Export or an Accessor Method Creator...) I will turn off strict 'refs' as well, and I want anybody else to do that then. But someone who isn't sure, must not break the rule.

Same with There's a "must", because you should not question until you know better.

Tabs: This is not about disk space, but it's no use disuccing this. Tabs aren't evil. :)

To clarify: whom are you making these rules for? Do you need to tell yourself "use strict, you(=I) know when I may disable it!"? Such guidelines are usefull in two ways: a) for people who learn Perl, for them I wrote the "MUST". To say "SHOULD" tells them there are exceptions, but there are no exceptions they need to know about yet. b) For a project, to keep it all consistent and easier to make many people work on the same Code. There the "MUST" fits because an exception should be rare and known, because it is an exception. And: I wouldn't work with people who need to be told to use "strict" and when to disable it.


Replies are listed 'Best First'.
Re: My coding guidelines
by Abigail-II (Bishop) on Nov 27, 2002 at 18:16 UTC
    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?


      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.


      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.


        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.


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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2021-04-18 22:00 GMT
Find Nodes?
    Voting Booth?

    No recent polls found