What a wonderful opportunity this week - to train delegates in Lua programming (and Lua, byte for byte, is perhaps the best value language that I train in) but also to be in on the early stages of a project where it's not just a question of training on the language itself, but also in helping provoke thoughts with regards to the best way to make use of the language in the application. I was happy - no, let's say "delighted" to step into one of the siderooms at the end of the class and find the team leaders discussing programming standards and techniques, to the extent that they're planning a further course on the subject. Good for them - I'm sure that such a course will repay its cost many times over! They asked me if I was interested in presenting - yes, interested, but I don't have the materials, the knowledge in some of the areas, and they would do far better with a more local tutor who could come back in for a morning every couple of months to review progress with individuals
I have, as is my normal practise, been writing code examples 'on the fly' during the course ... and on one of those I wrote today, I asked for a critical review from my delegates. In the culture, where everyone is so polite, I had to trigger the discussion - "I can see at least three things that I haven't done, which I should have done to make this into a high quality piece of code". And then they started to pick up my faults - (most of which were deliberate!)
• My code was uncommented throughout its body, meaning that it would be very hard to follow later, even by the original author.
• Variables within functions (at least I HAD structured my code into functions!
) were not all declared as local
- like Perl, Lua's variable are default global. And that means the a reuse of the function later could lead to some odd and hard-to-find bugs due to name conflicts
• The indentation of my code was erratic, again making it hard to read
• My functions, which would have been useful in other applications of the same data, were in the same file as my main program, meaning that without re-engineering my code could not be shared.
• Variable naming wasn't standard or consistent ... and we had already seen during the course how inconsistent variable naming slows down maintenance coding as the maintainer has to keep looking back to find out what variables were called, and what spellings and capitalisation were used.
• The output from my program was just a set of results - it didn't label the results in any way. So that means that a copy of the output given as a report to a manager would have needed extra work to document it to make it of any practical use
• There was no header block stating what the field was, which version, who maintained it, what it required. Once again, that makes it very hard to maintain.
• No user documentation ...
Our next Lua Programming course starts on 10th August 2009 in Melksham, UK. If you have missed that date, the course description page
will give further dates - usually scheduled 9 to 18 months ahead. And if you're looking for a course for a group of delegates, we can arrange a private course at our centre
or a on site course at your offices
for you. And as you'll see from the blogs I am writing this week, that can be in the UK, or further afield ... look back and you'll read of courses in the USA, Saudi Arabia, Germany, Ireland, the Netherlands, Slovenia, Finland ... and this week Mexico.
I believe in teaching NOT ONLY the mechanisms of a programming language, BUT ALSO how that language should be well written - both in terms of the specifics for the language and in general computing terms!
. If asked to teach "just the mechanisms of the language" on a private course, I would probably refuse, insisting on adding at least a few words to encourage good practise. (written 2009-07-30)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesU101 - Introduction to Lua. 
Training in Lua - (2007-03-16) 
Lua Course - here is the index - (2008-07-03) 
If you are learning Lua, here are some more examples - (2008-07-06) 
Rules, suggestions, considerations for Lua variable names - (2008-08-05) 
Lua Course, and the Wiltshire Countryside too - (2008-10-16) 
Learning to Program in Lua - public / open training course / class - (2012-05-09) 
Line, block and nested comments - Lua compared to other languages - (2014-05-04) 
Learning to program - variables and constants - (2014-11-22)Q101 - Object Orientation and General technical topics - Programming Principles 
I have not programmed before, and need to learn - (2009-01-19) 
Pre and post increment - the ++ operator - (2009-02-03) 
Where do I start when writing a program? - (2009-06-11) 
Planning! - (2009-08-08) 
Variable names like i and j - why? - (2009-09-22) 
The music of the stock market - (2009-11-22) 
Do not copy and paste code - there are much better ways - (2009-12-26) 
And and Or illustrated by locks - (2010-01-17) 
Improving your function calls (APIs) - General and PHP - (2010-04-24) 
Easy - but for whom? - (2010-05-18) 
Program for reliability and efficiency - do not duplicate, but rather share and re-use - (2010-07-19) 
Looking up a value by key - associative arrays / Hashes / Dictionaries - (2010-08-11) 
An introduction to file handling in programs - buffering, standard in and out, and file handles - (2010-09-21) 
Coding efficiency - do not repeat yourself! - (2010-11-02) 
Stepping stones - early coding, and writing re-usable code quickly - (2011-09-24) 
What order are operations performed in, in a Perl expression? - (2011-12-07) 
Dark mornings, dog update, and Python and Lua courses before Christmas - (2011-12-10) 
Some terms used in programming (Biased towards Python) - (2011-12-12) 
Object oriented or structured - a comparison in Python. Also writing clean regular expressions - (2012-03-26) 
From Structured to Object Oriented Programming. - (2012-10-02) 
Storing your intermediate data - what format should you you choose? - (2012-11-20) 
Lesson 1 in programing - write clean, reuseable and maintainable tidy code - (2012-12-16) 
Web and console - same principle, same code - Ruby example - (2013-02-14) 
Seamless, integrated IT - we have a long way to go! - (2013-04-11) 
Test Driven Development in Python - Customer Comes First - (2013-05-16) 
We not only teach PHP and Python - we teach good PHP and Python Practice! - (2013-06-18) 
Rooms available tonight - how to code an algorithm from first principles - (2013-08-19) 
Writing the perfect program in Tcl? - (2013-11-13) 
Learning to program - what are algorithms and design patterns? - (2014-11-22) 
Hungarian, Camel, Snake and Kebab - variable naming conventions - (2016-01-03) 
Remember to ask the question before you listen for the answer - (2016-01-26) 
What are callbacks? Why use them? An example in Python - (2016-02-11)
Some other Articles
Passing parameters to a coroutine in LuaSeeing Guadalajara - a first glimpse downtownWhat are closures in Lua?Floor to ceilingLearning to write high quality code in LuaLua training class in SpanishA new place in picturesBreakfast in MexicoMelksham to Mexico for the weekHot Tap at West Wilts Show