Learning and understanding scripting programming techniques
Archive - Originally posted on "The Horse's Mouth" - 2008-04-08 07:39:02 - Graham EllisCan you have a book about programming that's not about a specific programming language? A course that covers useful techniques across the board? That applies right across languages, with tips and techniques and things to bear in mind? Now there's a challenge, and I think the answer would be "yes." And the book/course could cover so many valuable topics ...
There are techniques that every programmer needs to know, over and above and beyond the basics of any one language. And they're rarely taught on any programming course, but would make such a huge difference, I know, to so many of our delegates. I'll give you some subject headlines - not sorted into any particular order.
Constants and config files and options
Programming with fixed values, and values that are changed at installation
Equality, looks like, min and max
Does 7 equal 7.0? Does SN12 7NY look like a postcode?
Comparing - old, older, oldest
Getting a value, comparing data, comparing collections of data
Cardinal Values
Numbers that are used as markers, and some cautions about their use
Letting it finish
Terminating processes and file handling neatly, avoiding garbage
Intermediate reports
How can I ask "how is my program doing" while it's running?
User inputs
Taking care of nasty values. Validation.
Efficiency
Technique "a" may take 3 days - and technique "b" 3 minutes.
Usability
Providing a consistent and understandable user interface
Merging data
Taking multiple data sets and combining them
Reusability and support
Writing code that can be reused, and easily supported
Test and Debug
Techniques for checking your code before it gets to the users
Singular v plural
"is" and "are". "child" or "children". It makes sense to report in good English
reporting zero answers
Should you just leave a blank, or say "no match?"
Interactive inputs?
You need to prompt the user if you're interactive, yet prompting when reading data from a file will make for a messy output display
Error Handling
How to provide good, consistent, useful error messages
Injection attack.
What about malicious users running your script.
Strings - upper and lower, rude words
Users who SHOUT, or who don't know how to capitalise!
Dynamic v static
When are variables created and lost? How are they shared between blocks of code?
Declare v initialise v Assume
What are the advantages / disadvantages of declaring variables, initialising them, v assuming an initial value
Overriding code
Conditionally loading code, and replacing code already loaded
Scope and Name spaces
variables which are local to a piece of code, which are shared between a number of pieces of code, and are shared throughout an application
OO approaches
Is it a good idea to use objects for xxxx job?
Hashes / Dictionaries
Data that is keyed by a unique value. But what if that value is not unique?
Sorting
How sorting works and used defined sorting. Sorting (or not!) hashes
Caching
Avoiding repetition by caching, and how to ensure that your caches are up to date.
Graphics and graphing techniques
World and screen co-ordinates, choosing your axes, watermarking pictures and more.
Specifying an API that can be extended
Providing an interface to your functions that works well and is easily supported now,and can be extended compatibly when new requirements are added
Web and Database
Accessing your scripts via a web front end, and saving the data in a database
Threaded Programming
Running process in parallel
Queues and Recursion
Making notes of places you need to come back to, and saving where you are when you need to go off to more code.
Security issues
Capture, Passwords.
Can it all be done without reference to language then? No - I don't think it can; examples will be needed and there are nuances in each of the languages. And with my knowledge / use of Perl, PHP, Python, Tcl/Tk/Expect, C/C++, Ruby, Bash/Ksh, and Java, I'm well placed to show how the techniques can be implemented in each of them.
If you're interested in having a day or two of "techniques" training - please let me know. And, yes, I would illustrate and have you practice in whichever of the language(s) from my list that's appropriate to you! Email - graham@wellho.net - and refer to this item!