diff options
| author | Paul Buetow <paul@buetow.org> | 2011-03-06 10:57:41 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2011-03-06 10:57:41 +0000 |
| commit | 213033db33be271791f2d9ff1c9c44c0bed79f18 (patch) | |
| tree | 1b3ff0d0eddfc7f6995afa67b5d3fc2ef8fa85a7 /STYLEGUIDE | |
initial xerl import to utils
Diffstat (limited to 'STYLEGUIDE')
| -rw-r--r-- | STYLEGUIDE | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/STYLEGUIDE b/STYLEGUIDE new file mode 100644 index 0000000..e6dd3c9 --- /dev/null +++ b/STYLEGUIDE @@ -0,0 +1,71 @@ +Always do: + +- Pragmatic modules ALWAYS to use in ALL packages: + + use strict; + use warnings; + +- Only for packages for including package UNIVERSAL definitions + + use Xerl::Page::Base; + +- Object oriented coding style + +- Always use method prototypes if possible + + sub foo($;$) { .... } + +- Explicit object typing if possible + + my Class::Name::Here $foo = Class::Name::Here->new(); + +- If no real ret val, set undef; explicitly + + sub foo() { + # Do some stuff + ... + # Set explicit undef ret value + return undef; + } + +- Private subs use _ as its prefix and are called only from the current package. + + package Xerl::Foo::Bla; + . + . + + sub _iamprivate($) { + my Xerl::Foo:Bla $self = $_[0]; + . + . + } + + sub iampublic($) { + my Xerl::Foo:Bla $self = $_[0]; + $self->_iamprivate(); + return undef; + } + +- Static subs (not OOP) are in CAPITAL letters. + + sub IAMSTATIC($) { + print shift; + return 'Hello World'; + } + + sub iamdynamic($) { + my Xerl::Foo:Bla $self = $_[0]; + return Xerl::Foo::Bla::IAMSTATIC( $self->get_somevalue() ); + } + +- Static private subs start with _ and are written in CAPITAL letters + + sub _IAMSTATICPRIVATE() { + . + . + } + +- Use Pidy to automaically restyle the code! (make pidy) + +- Mark things which are still to do with TODO: at any place in the source + tree. (Can be searched for using 'make todo'). |
