Programming

Articles pertaining to the writing of code

PHP Puzzler: Forgetful Variables

Today I present to you a PHP puzzler that in fact had me stumped for a day or two. I do enjoy when a language throws a curve ball; it presents an opportunity to gain insight on the mechanics and become acquainted with the nuances of the language in question.… Read the rest

Java 7 launches – new language features introduced

Java 7 is now officially available as of July 28th 2011. The intent of this blog entry is to introduce the new language features. For further details, consult the Java 7 SDK.Binary Literals Underscores in Numeric Literals Strings in Switch Statements Type Inference for Generic Instance Creation Try-With-Resources Improved Exception Handling Improved Compiler Warnings and Errors When Using Non-Reifiable Formal Parameters with Varargs MethodsBinary Literals [Official Docs] Long awaited, Java now allows for integral literals (byte, short, int, and long) to be expressed in binary.… Read the rest

Readable Code vs Compact Code

Inspired by a thread on Facebook to which I contributed, a few words concerning readable code vs compact code. When writing applications, a common scenario involves setting a variable from some external source. What immediately ensues is a check to ensure that our variable has some meaningful value.… Read the rest

Code Commenting – a delicate art of balance

Taken from my reply to a post regarding the topic on Facebook, a few words introducing key guidelines I follow when commenting my code. Regarding classes, I like to provide a class summary stating the intent and purpose. Accessors, Mutators, Constructors – I don’t feel the need to comment them as their roles are (and should be) rather self-explanatory.… Read the rest

Array unpacking in PHP

One of PHP’s less known language constructs is list(), very useful for unpacking indexed arrays. Consider the following simple example denoting its usage: This clean, readable, scalable approach is great for processing data records, unpacking an SQL result row, etc. The only shortcoming, list() cannot be applied to an associative array.… Read the rest