perlmeditation
hakkr
With respect to this <a href="http://www.perlmonks.org/index.pl?node_id=57950">node</a> and <a href="http://www.perlmonks.org/index.pl?node=perlstyle">perlstyle</a><p> I am composing some house rules/guidlines for our CGI programmers. Whilst some may be specific to our shop the idea is to promote good maintainable programming for a team environment. Hopefully this list will set the standards for our code reviews without cramping style to much. I'd appreciate any comments or input from anybody else who has written similar guidlines. I think some security focused rules may make good additions</p>
<READMORE>
1. use strict and warnings<br>
2. use HTML::Template not HERE documents<br>
3. no deliberate obfuscation<br>
4. all files must be documented with POD (Author, Date created, synopsis, description)<br>
5. OO always to be used where possible<br>
6. Pass by reference<br>
7. No hardcoding of values especially file paths, script names etc<br>
8. Config files or config scripts to be used<br>
9. Do not reinvent wheel always check CPAN<br>
10. minimise coupling<br>
11. maximise cohesion<br>
12. maximise reuse <br>
13. Always indent logic<br>
14. Any reused code block above 5 lines must become a sub routine<br>
15. Always retrieve database rows into hash reference not arrays<br>
16. Use CGI CARP<br>
17. Assign CGI parameters to hashes<br>
18. Version history at bottom of file<br>
19. All subroutines to be commented<br>
20. Meaningful Subroutine and Variable names to be used<br>
21. Constructors must only create objects<br>
22. Program flow control to be places in 'main' method<br>
23. No Global Variables<br>
24. use my not local<br>
25. All Perl filehandles should be in all uppercase<br>
26. Always use CGI.pm <br>
27. Use verbs for subroutines, use nouns for variables, be descriptive and consistent.<br>
28. Do not use $_ <br>
29. Do no use goto <br>
30. Initialise variables <br>
31. Error handling done using Begin blocks at CGI level. All dies are logged <br>
32. Where code returns a result it should do so or die with a meaningful error and $!<br>
END