Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Meaning of "Clean" Perl code

by eyepopslikeamosquito (Chancellor)
on Jul 25, 2005 at 15:21 UTC ( #477868=note: print w/replies, xml ) Need Help??

in reply to Meaning of "Clean" Perl code

It is perhaps easier to describe "unclean" code. For example:

  • Code with lots of code smells.
  • Lots of magic numbers.
  • A 5000-line main program.
  • A sub that reads and writes global variables.
  • A sub that does not have a single purpose; for example, instead of a sin function and a tan function, someone defines a sin_and_tan function.
  • Some of a sub's parameters are not used.
  • A sub that is 1000 lines long, aka "Big-Arsed Function".
  • Duplicated code.
  • Code with gaping security holes.
  • Code that leaks resources.
  • Code that is not thread-safe or signal-safe.

Conversely, some clean Perl code attributes are:

  • strict-safe.
  • warnings-safe.
  • taint-safe.
  • Good variable naming.
  • Minimize variable scope.
  • Prefer lexicals to globals.
  • Good commenting.
  • Consistent indentation and visually pleasing layout.
  • Easy to understand.
  • Simple, Clear, General.
  • Easy to use module interfaces.
  • Comprehensive test suite.

Finally, TheDamian's new book Perl Best Practices provides much sound advice on writing clean Perl code.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://477868]
[Happy-the-monk]: holli: Heizungszü ndungselektrik?
[holli]: Happy-the-monk: not quite
[holli]: I just ordered a pair of deans connectors to replace them. probably propriatary

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2017-11-19 14:43 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (281 votes). Check out past polls.