Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Meaning of Maintanability and Functionality in Coding Perl

by graff (Chancellor)
on Oct 18, 2005 at 05:30 UTC ( [id://500884]=note: print w/replies, xml ) Need Help??


in reply to Meaning of Maintanability and Functionality in Coding Perl

How can I tell if my Perl code (or others) is 'maintainable'

Look at something you wrote at least six months ago (i.e., something you haven't looked at in at least six months), and see whether you can understand it. If it didn't include "use strict", make a copy, add "use strict" to it, and see how long it takes to make it work like the original.

If it had "use strict", but not "use warnings" (or "-w" on the shebang line), add that as well, and see (1) how many warnings you get, and (2) how long it takes to make them all go away (while still making it work like the original -- assuming the original was doing the right thing ;^).

Look for repeat occurrences of:

  • The same quoted string (or many strings that all have some common substring)
  • The same "if" condition
  • The same sequence of steps in different loops or subs or sections of the main code (with just some differences in the literal values or variables being used)
The more repetitions of strings, conditions or procedures you have in your code, the less maintainable it is.

(If your code already has "strict" and "warnings", post a snippet of it here, and see how people react to it.)

As for "good functionality", that's what we call "an empirical question" (i.e. testable): does it do what it is supposed to do, or not? You could change the question slightly, to "does it do its job effeciently?" but this isn't always relevant. In general, if it does the job without a lot of unnecessary steps, that should suffice.

As for points to pay attention to, the most important one is documentation! Write a coherent, human-readable description of what a program is supposed to do (what are its inputs and outputs, what goals does it accomplish, and -- briefly, succinctly -- how does it work), and do that first . Then write the actual code, in accordance with the description. Keep the description in the same file with the code, in pod format.

  • Comment on Re: Meaning of Maintanability and Functionality in Coding Perl

Replies are listed 'Best First'.
Re^2: Meaning of Maintanability and Functionality in Coding Perl
by pg (Canon) on Oct 18, 2005 at 06:01 UTC
    "Look at something you wrote at least six months ago (i.e., something you haven't looked at in at least six months), and see whether you can understand it."

    I agree with you that legibility is part of maintanability. Just to add a little bit more: legibility does not directly gurantee maintanability. For example, we have this one application that is over-engineered, and the architecture determines that it is very difficult to maintain, even if all of the code are very easy to read and understand, the maintanability is still very poor.

    Maintanability at least comes at two levels: coding level and application level (design and architecture).

Log In?
Username:
Password:

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

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

    No recent polls found