Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Code Efficiency: Trial and Error?

by oakbox (Chaplain)
on Oct 11, 2002 at 20:57 UTC ( [id://204662]=note: print w/replies, xml ) Need Help??


in reply to Code Efficiency: Trial and Error?

I find that I stick to a few simple constructs: foreach over for or while, if-else in brackets over the ?: notation, etc. I write code faster when I'm using tools that I am very familiar with and only jump to other coding styles when there is a real need for optimization.

The main criteria is consistency. If you are consistent in your style, you can go back to your own code and immediately grok what's going on. Consistency also helps other people reading you code.

The question wasn't 'correct vs. bad' coding. If you are consistently writing bad code, then you need to change :) But if the choice is between 'good' and 'also good' consistency wins.

oakbox

Replies are listed 'Best First'.
Re: Re: Code Efficiency: Trial and Error?
by Sihal (Pilgrim) on Oct 11, 2002 at 21:09 UTC
    Well... I often ask myself the same question. I often do things in a very readable way, that works well, no bugs etc... And then my boss will come, hack the code, make it two times shorter, and result in a faster more efficient way. Often not as readable though.
    I also often wonder when building regexes if Im using the fastest way. It would be nice to have examples of two regexes doing the same thing but one faster than the other, and explain why it is faster, so that we can understand how to write more efficient code.
      you might want to check Mastering Regular Expressions by Jeff E.F.Friedl for a deep coverage of regular expressions, with a whole chapter dedicated to perl's regexes.

      btw, that book review is for the first edition, so you might want to know there is a second edition published in july 2002.

      hope this helps,

Log In?
Username:
Password:

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

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

    No recent polls found