Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
Do
  • Do use CGI, or CGI::Simple.
  • Do use strict and warnings and CGI::Carp from the start.
  • Do use templates (HTML::Template or Template::Toolkit)
  • Do write yourself a requirements list if possible.
  • Do design the whole thing before you start
    • what administration pages will you need?
    • what sequence of events will customers follow?
  • Do create your test cases and scaffolding before you start.
  • Do make paper webpage mockups and walk through the client process with a non-geek, perhaps your father?
  • Do try to identify all the code you can dump into separate libraries
  • Do consider OO where it might be useful.
  • Do search CPAN, freshmeat and sourceforge to see if your system or parts of it have already been done before.
  • Do ask here to see if we know where it's been done before.
  • Do use CPAN modules to do the parts of your project that they can.
  • Do make sure that the modules you choose to use are well supported and suit the task you're using them for.
  • Do use taint checking. Lots. Always.
  • Do expect to throw parts away once you've found a better solution
  • Do throw away parts when you've found a better solution
  • Do use DBI and its friends if it's DB related
  • Do investigate the pros and cons of different databases before starting
  • Do read about useability and try to design your system to be useable by a large range of skill levels and disabilities.
  • Do think about open-sourcing the end result if you're happy with it.
  • Do comment it thoroughly
  • Do be consistent in your coding style - and please use one that is considered "standard" (K&R, GNU or another)
  • Do try to keep each subroutine less than two screenfuls (ie less than 50 lines) because even if you don't succeed it's a good metric.
  • Do try to refactor as much as possible, whenever possible so that your library code grows faster than your scripts do.
  • Do test and test and test again. And get someone else to test too.
  • Do use a decent change management system such as CVS. Use it properly and tag releases (where it compiles, works and is stable (though not necessarily complete)).
  • Do document your module/function interfaces and keep these documents up to date.

Don'ts

  • Don't expect it to be easy
  • Don't skim on requirements or design
  • Don't reinvent the wheel just for the hell of it
  • Don't refuse constructive criticism
  • Don't write ugly code and then beg us to fix it for you :)
  • Don't give up, large projects are a great way to improve at your chosen language.
  • Don't use global variables unless you absolutely need to, in fact, don't use them then either.
  • Don't hardcode in URLs, filenames, HTML headers, magic numbers. Try to move these to a good localisation module.
  • Don't turn strict off. If you need to turn it off, you're probably trying to do something a wrong way.
  • Don't keep code just because it took you ages to write it. When you've found a much more elegant/efficient/effective solution, fix your code.
  • Don't spend all your time worrying about finding the absolute best way to do something. Do it any way the first time and come back and rewrite at your leisure.

Update:A few more don'ts.


In reply to Re: Writing a large application in perl? by jarich
in thread Writing a large application in perl? by BUU

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.