Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
perl coding standards

Posted by serrie_justine (serrie_justine), 10 December 2004
Hi All
I recently attended the geekmas weekend - which incidently I greatly enjoyed.  During the discussions about Python/Perl paddy made a point about the fact that Python is likely to force people to write cleaner code.  Whilst being a strong advocate of perl I will have to agree with him on this one as we have many in-house written scripts which are illegable and often buggy.  Due to the fact that these scripts are mostly not deliverables and are there mainly for assisting us to get information out of the relevant tools that we use, there is not much importance placed or control over how to write these.  
We're therefore looking to discuss putting forward a simple coding standards  to try and get people to write tighter more legible scripts which will make it easier for others to debug.
an example I have found is
http://www.bbc.co.uk/guidelines/webdev/AppA.Perl_Coding_Standards.htm
are there any other coding standards that people here would advocate as it would be nice if I could have a full list of options to put forward to our site before cherry picking the best ones - or the most likely ones that people will adopt without whinging!  
Cheers  

Posted by Custard (Custard), 10 December 2004
Hi, nice to meet you again.

For Perl:

perldoc perlstyle

Although personally, I like 'cuddled' elses and I use a more Java like naming convention for methods and variables  (MyMethod  myVariable etc..).  Class names always begin with an uppercase, and variables always lower. (This avoids issues when perl sometimes can get confused between class and variable names. I can post a demo if you need explanation).

I think you can write awful code in any language (including python) that no one would understand.
But Perl is probably easier to write horrendous looking code in. (Possibly competing with C here.)

I think some of the most useful things you can do to make code more understandable are:

*) use strict; use warnings;

*) Include a POD section. I have a template for Perl classes which includes a boilerplate POD section.

*) Include a quick comment at the top of each sub describing what it does, what it's inputs are, and its outputs if they are not obvious.

*) And of course decent descriptive names for subs and variables.

Perhaps you could use perlstyle as a basis, and modify if you have particular preference for something.

My 2p'th.

HTH

Posted by serrie_justine (serrie_justine), 10 December 2004
and Hi to you again  
We've already put forward the perldoc/perlstyle to be discussed at the meeting - as it is a lot of it will be overkill - I think just to get people to always ensure that they have checks throughout their scripts to ensure that the commands have worked and to use $! to see why not would help in many cases.  Being hardware engineers they generally mostly use system commands and assume that they work - which we all know is a very silly assumption to make!! use strict and use -w might be pushable with them - although even that may take some coaxing.......  

Posted by admin (Graham Ellis), 11 December 2004
What an important / vital subject!  I'm a great one for suggesting guideline standards and I've been reading the BBC link described above.  Expect a futher follow up from me by the end of the weekend - it's something I want to think through and not just for this particular poster  

Posted by admin (Graham Ellis), 12 December 2004
I've meant to put some thought to Perl standards for a long time, and I've just produced a draft set which is intended as a starting point.

Some folks want a long and detailed standard, and others want just a few thoughts / suggestions / guidances / rules.  So I've marked up five things our of about 30 as my "Golden Rules":

Golden Rule 1 - Consider WHY you're writing the code
Golden Rule 2 - Consider ALL parties when you're writing the code
Golden Rule 3 - Provide good comments AND good user documentation
Golden Rule 4 - Think about reusability
Golden Rule 5 - use strict and use warnings

And I've put the whole document at http://www.wellho.net/resources/perlstandards.html

Feedback / comments most welcome

Posted by dcorking (David Corking), 21 December 2004
on 12/10/04 at 10:03:45, serrie_justine wrote:
it would be nice if I could have a full list of options to put forward

Hi Serrie - good to see you again.

Last night I got distracted by Google and stumbled on the intelligence that Damian Conway of the Perl 6 team is writing a book called "Perl Best Practice".   Apparently he has given out handouts at courses he presented http://damian.conway.org/Courses//BestPractice.html  http://conferences.oreillynet.com/cs/os2004/view/e_sess/5053, but they are not available online as far as I can tell.  Sounds like it is worth keeping an eye out for - or perhaps being bold and offering to review a draft of the book  

Graham Ellis - I hope that posting a link to a trainer in Australia doesn't scare your competitive instincts.

Posted by serrie_justine (serrie_justine), 21 December 2004
Hi David
Hi again! Thanks for that - it looks pretty good.  Good idea about reviewing the book - the guy looks like he's quite up on his subject and seems to have pretty relevant titles affecting most of the untidy areas of perl.  I'll let you know if I manage to get anything out of him by posting it up here.
I'm sure Graham can cope with the competition - besides this will merely alert him to probably the only O'reilly book he hasn't yet got in his library   (even if its not yet released)

If I don't get anything before friday then have a good christmas and new year - and to everyone else watching this thread  


Posted by admin (Graham Ellis), 23 December 2004
Hi, folks.  I've seen Damian Conway present an advanced Perl subject and he's one of the best - someone who both knows his stuff technically and who knows how to present it.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho