You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

The backend Perl code must conform to the following style guidelines. If you find any code which doesn't conform, please fix it. These requirements are intended to maintain consistent, organized, professional code.

Indentation

Proper indentation is very important.  Just because the code lines up properly in your editor of choice, does not mean it will line up properly for someone else working on the project.  This can be very annoying.  These requirements will prevent this.

Tabs

Tabs should be used to indent all code blocks.  Spaces should never be used to indent code blocks.  Mixing tabs and spaces results in misaligned code blocks for other developers who prefer different indentation settings.  Consider the following code block which is indented with all tabs (shown with and without whitespaces):

Indented properly with tabs
Indentation width set to 3
Whitespaces shown

Code is lined up properly

Indentation width set to 8
Code remains lined up properly


Now consider a situation where another developer is using an editor which is configured to indent using spaces by default.  The developer makes changes to 1 of the lines:

Indented incorrectly with a mix of
tabs and spaces

Code appears lined up to the
developer who messed up the
indentation

Code is not lined up for other
developers

Comments

Variable Names

meaningful

No caps unless class var

use underscores

Subroutine Names

No caps!

Use underscores

POD Documentation

Curly Brackets, Parenthesis

if($total_hours >= 13 && $diff_hours >= 23 && $diff_minutes >= 55){

If/Else Statements

Heredocs

  • No labels