Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: PBP: Code Layout

by BrowserUk (Patriarch)
on Oct 19, 2005 at 22:39 UTC ( [id://501460]=note: print w/replies, xml ) Need Help??


in reply to PBP: Code Layout

Like most people, I have my own preferences for code layout. I tend to use more horizintal whitespace and less vertical than other people.

But the single most important rule in my book is:

Above all, be consistent!
.

Personally, I'm gonna code new code, my way. This less through beligerance than the simple fact that having to stop and think about style, rather than letting it flow naturally, imposes too high a price in terms of distraction from the task of programming.

If client rules absolutely insist, I'll use a code beautifier to re-format my code to the "house style" when I'm done with it, or at checkin. With most code editors it is fairly easy to set up macros to run the beautifier to house rules and then do check in and to my preference on checkout.

That said, when I pick up someone elses code, if I am only browsing or making a simple change, then I'll skip the reformating, if they have a consistant style. It is generally fairly easy to aquire a good eye for whatever style is used, if it is used consistantly.

If they don't, and/or I need to get a good understanding of their code, I'll more often than not reformat their code by hand, line by line, from the top to bottom. I find that the process of going through the code doing this forces me to actually read each line rather than just scanning it.

Reading and familiarising yourself with a piece of code, even a piece of your own from a few months ago is the single best way of avoiding making silly mistakes. It only takes a few minutes to do and saves so much time in the long run.

Generally, I am pretty skeptical of the "simple code avoids maintenance problems" argument. Personally, it is rarely making changes to moderately complex code where I make silly mistakes. It is the quick, "obvious" changes to simple code, where the mistakes creep in.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 08:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found