Development

No more pets in IT

Remember the good old days, when IT got a new server. It was a special event - and naturally the naming game. Finding that special name for the server, which neatly fitted into the naming scheme adopted (be it Indian cities, Nordic mythology or cartoon characters). This ought to be then, but the ceremony still happens regularly in many IT departments, where servers are treated with the same affection as with pets - and with all the bad side effects it may bring along.

How not to become the maintenance developer

As a developer it seems, you always seem to strive towards producing ever more complicated code. Utilizing new frameworks, adopting an ever evolving “convention before configuration”, pushing object-oriented programming - maybe Domain Driven Development - are practices introduced, refined and explored in the quest to prove yourself as a steadily better developer with rising skills. Yet to what point? While the intricate complications may impress fellow developers, doing so often digs a hole which may be pretty hard to get out of.

Trying and failing (twice)

PHP like many other programming languages has facilities to handle exceptions. Using them is pretty easy, but sometimes lazy programmers seems to misuse them to suppress error messages. A try/catch in PHP is usually constructed something like this: try { // Something can go (horribly) wrong... } catch { } The lazy programmer may leave the catch empty, but frankly you should never do it. When you’re doing something - try’ing - it’s for a reason, and if it fails, someone quite possible need to know - the end user, a log file for the sysadm or someone else.

strpos in PHP - like being stung by a needle in a haystack

In PHP when you have a string and want to find out if it contains another string, there are a few ways to do it. You can use regular expressions, use the strstr functions and a few other methods. The easiest way though is probably by using strpos, which returns the number of the character containing the first occurrence of the thing you’re looking for - and false if the string isn’t found.

memcache: set vs. replace

When using memcache from PHP, you can save values with either set or replace. You can probably safely ignore the replace method: “Memcached::replace() is similar to Memcached::set(), but the operation fails if the key does not exist on the server.” - PHP Documentation