Archive for the ‘Software Engineering’ Category

Why Does Extreme Programming Work?

Saturday, August 30th, 2008

Here is a piece of cynical thought: Extreme Programming works not only because of its inherent traits, but also because of some interesting side effect.

Let’s start with two simple questions: how many times have you been interrupted in your work today; be it by your boss, your superior officer, or one of your colleagues? What were you doing when you experienced the interruptions?

Those of you who, most of the time, work solo in your cubicle probably experience the most interruptions. And you were probably staring at the monitor, trying to make sense out of some important piece of code or technical document.

The reason you get interrupted is because other people do not believe that you are doing actual work, regardless of how legitimate your endeavour was. Think about it: when you are staring at the monitor, most likely the font is too small for a bystander to read with ease. If he cannot read with ease, he won’t bother with reading and will not be convinced that you are busy. Therefore he assumes that it’s ok to bother you.

Now, have you ever noticed how, sometimes, your boss walks towards you, only to realise that you are on the phone with somebody business-related, so she walks away within 5 seconds without bothering you? The reason your boss walks away is because she can hear all kinds of jargon in your conversation, so they assume (rightly) that you are onto something important.

I have come to hypothesise that one gets the fewest useless, unscheduled interruptions if he picks a working methodology that involves lots of talking, thereby letting uninvolved parties hear lots of jargon. When people hear jargon, they suddenly find reason to believe that you are doing actual work. For this reason, Extreme Programming becomes a good candidate. When you practice Extreme Programming, you are inevitably paired with a colleague, sharing one computer. When two people work together at the same computer, they inevitably talk a lot more than if each of them were working solo, and therefore they will let people around them hear a good load of jargon.

There you have it, the side effect that contributes to the effectiveness of Extreme Programming.

Note: this post is entirely meant as a meek piece of I.T. workplace satire. It is not to be taken seriously. Dear Kent Beck, if you happen to be reading this, please don’t get mad.

Gentoo Is Not for Everybody

Friday, August 22nd, 2008

Gentoo Linux is not for everybody, seriously. And by that I don’t mean only the average computer user, but also the majority of application developers. Of course, this is just my opinion, which I will explain below. I do not in any way mean that Gentoo Linux is inferior to other distros either; it’s great for people who care about customisation and speed, but not for those who just want a stable, working development environment.

To many people, the biggest attraction of Gentoo Linux is that you are effectively rolling your own flavour of Linux when you install it because you pick, configure, and build everything, even the installation CD. This aspect is different from most other Linux distros for which prebuilt installation CD images and binary software packages/repositories are available. The primary reason for picking, configuring, and building everything from source is the performance gain that results when the compiler and linker are optimising code for a particular architecture, even more so if object code is statically linked.

The majority of application developers, however, do not care about the performance of the OS hosting the development environment. Therefore, the performance gain from compiling everything from source is largely irrelevant to the application developer.

Furthermore, the difference in performance between Gentoo and other distros shall be significantly reduced nowadays. Gentoo, when it was still known as Enoch, used a fork of the GCC that provided about 10% performance gain over the mainstream, official version of GCC. This difference in performance no longer exists since the fork has been merged back into the official version of GCC. If you don’t care about the performance difference that remains, you might as well download binary packages; but if you are using binary packages, what’s the point in using Gentoo?

The Portage package system that Gentoo uses is also not something that the average application developer would like. Many of the packages have too many build options, and sometimes these very same options are under documented. For instance, the last time I counted, the package for the Apache server has around 60 build options, which do not exactly correspond to the options used with the configure script of the official source package from httpd.apache.org. Documentation of the options is impossible to find; even the popular Gentoo-Portage website has no information (http://gentoo-portage.com/www-servers/apache/USE#ptabs). Some of these options conflict with each other; the only way to eliminate all of the conflicting options is by repeatedly trying to install the package, allowing the portage commandline interface, emerge, to report conflicts one at a time, so that you can eliminate one of the conflicting options one at a time.

The application developer has enough to keep his hands busy and his mind on the brink of insanity. He cannot afford to lose time with compiling the development environment.

Gentoo may be great for top notch performance in the live, production environment; but if anyone asks me to pick a distro for development environment, I would pick Ubuntu over Gentoo any day.

Mobile development sucks - The cast

Tuesday, July 1st, 2008
I think that the people involved in my story can be divided into the following four parties:
  • My Boss, a GM
  • Me and my colleague, (junior) consultants by title, we are actually more like software testers in this project 
  • Our programmers for the various mobile phone platforms
  • Our client, a mobile network operator in a foreign country

Do you realise what’s wrong with this cast? I think I DO.

Where the hell is the project manager, the person who is supposed keep everybody in check? When I say “everybody,” I make no exception to the GM because the GM does not always remember that the underlings are all up to their necks with work. A project manager would be the person who makes a scene with the GM to refresh the GM’s memory. Underlings like me are too busy hacking away already, you know; they don’t have time to defend themselves against the waves of order from the GM.

And why is there no software architect? Who is supposed to guide the design and specification of our product? Who is supposed to keep all the different platform versions from careless differentiation? It doesn’t take a genius to understand that I can’t act as the software architect: I have neither the knowledge nor the experience related to mobile development.

Oh, did I mention that there is no infrastructure support? The developers didn’t even have a version control server that they can commit their work into because there is nobody to set up such an environment and the developers certainly have neither the permission nor the time for such.

Mobile development sucks - Prologue

Monday, May 12th, 2008

It’s been six months since my first full-time job has begun. The first month was spent in learning two products, of which I never got involved in any project. My boss finally decided to let me pick up a product development project that has been going on since before I joined the company. I must say that it has been a great learning opportunity so far and I want to share what little wisdom I have found.

Let’s start with some basic information:

  • The product is a software application for smartphones;
  • We are trying to support 5 smartphone platforms. I’m not talking about phone models - that would have been trivial. I’m talking about something more in line with a situation like Mac + Windows + Linux + Amiga.
  • As much as possible, the application is written in native code on all supported platforms (as opposed to Java, which would have been easier to port);

If you think that this is starting to stink, it gets better:

  • There is no vision document; the only available material that’s close to a vision document is a bunch of PowerPoint presentations;
  • There is no software requirements specification, not even an informal one;
  • There is no software architecture document, again, not even an informal one;
  • There is no software design document at all, again;
  • There is an overly simple blackbox testing checklist;

You probably saw this coming by now:

  • The programmers had started coding the damn thing and submitting test builds already.
If you think that this point above puts the final nail in the coffin, I am sorry that I must disappoint you. Read on.
  • There are, not one, but two versions of the product, with two different product activation models. Not only do you activate the two versions in different ways, but the sets of features that are disabled due to lack of activation are also different;
  • The two versions were being developed concurrently.
I suppose my dear reader has a good picture of the stage in mind now. I’ll let you sleep on it for a bit so you can imagine what can go wrong as the story unfolds itself.

One thing about Mac OS X that annoys me.

Friday, October 5th, 2007

Keyboard input methods - this is one thing that has been bugging me since my switch to Mac OS X.

Actually it is more like 3 problems.

The first one is the way I have to cycle through input methods using Cmd+Space and Alt+Cmd+Space. I know 4 languages (Chinese, English, French, and Japanese) and as a result use 7 keyboard layouts/input methods daily (English, French, Simplified Chinese Pinyin, Traditional Chinese Pinyin, Cantonese Pinyin, Hiragana, Katakana). Cycling through the keyboard layouts and input methods is becoming tedious. I still prefer the Windows way, where I can assign a keyboard combination (e.g. Alt+Shift+1) to each keyboard layout and input method.

The second problem is the lack of official support for non-West-European input in the X11 environment. All attempts to build, install, and use UIM or SCIM have been unsuccessful.

Finally, the Traditional Chinese Pinyin input method seems to be a bit quirky. Sometimes it tends to feed out the wrong character. For instance, typing “zhang1″ gives me “章” among the candidate characters, but if I select that character, the input method sometimes feeds the “杖” character instead.

Apple, please tackle these problems in the near future. I believe it will do you good in expanding your market in East Asia.

PopupGallery, now pageable

Monday, April 9th, 2007

Some of you may have used the PopupGallery available at Yellow Swordfish. In the last few days I made changes to it so that the hover gallery automatically becomes pageable if there are too many pictures to be fitted on the page. You can see an example at my test site. The modified plugin package is available here.

Date and Time in PHP 5 and MySQL 5

Tuesday, March 13th, 2007

Time for a little technical post.

Date and time manipulation are one of the most common components in web applications. This is true for a few reasons:

  1. Web applications can have users coming from anywhere around the globe, under many different timezones.
  2. Chances are that you receive date and time information when the user does something. For instance, a user sends an e-mail and there is a timestamp in the message header.
  3. Chances are that you want to do something about the timestamp. For instance, sorting e-mails according to the timestamp before showing them to the user.

Unfortunately, the PHP date and time manipulation functions are anything but properly documented by the PHP documentation team. This causes a lot of grief and frustration among novice PHP programmers. Here, I will talk about how to handle dates and times in a PHP 5 + MySQL 5 setup.

Always store dates and times in the UTC timezone.

This is a good idea for 3 reasons:

  1. The UTC time reference is the most precise and least debatable there is on Earth because it is based on atomic time and takes the Earth’s rotation speed into account for compensation. Furthermore, it has never been, is not, and will never be subject to the daylight saving rule.
  2. The UTC is already the preferred reference timezone among application developers. The Unix Epoch, for instance, starts on midnight of January 1st, 1970, UTC time. Therefore, storing dates and times in UTC will allow easier interoperability with other applications right off the bat.
    1. A consequence of the above is that robust conversion routines to and from UTC is likely to be available in any programming language you pick (including PHP).
  3. You never know when you may need to move or deploy your web application to a host on a different timezone, therefore you don’t want to rely on the server’s timezone for storing and converting dates and times.

Dealing with date and time in PHP 5

Let’s face it, the php.net documentation sucks. One of the issues I see in it is that it fails to adapt to the OOP paradigm. It’s a shame that OOP has been introduced to PHP 4 and 5, and yet the documentation is still largely function-oriented. PHP 5 comes with a class library, but most people whom I have talked with do not know how to use it because the classes are not well documented. As such, most PHP 5 projects are still largely procedural. My goal here is to bring you a little bit of enlightenment by explaining how to use those classes.

  1. First, you need to create an object to represent the timezone. This step is not strictly necessary, but is recommended because in a globally connected world, a time value by itself is meaningless. The DateTime constructor can optionally take it as an argument, which is the way I recommend you to use it.
    $timezonename = 'America/Montreal';
    $mytimezone = new DateTimeZone($timezonename);

    Note that $timezonename can be any timezone name supported in the Olson timezone database (a.k.a. zoneinfo) or any of the few extra ones. You can see the full list in Appendix I of the php.net documentation.

  2. Only then do you create the DateTime object.
    $datetimestring = '2007-03-13 23:10:00';
    $mydatetime =
      new DateTime('2007-03-13 23:10:00', $mytimezone);

    The exact acceptable format of $datetimestring is the same as the GNU Date Input Formats, in case you have not found out from the php.net documentation already.

  3. Now, let’s try outputting it as a string. The bad news is that you should not do echo $mydatetime; The good news is that you can decide what string representation to take by using the DateTime::format() method.
    $mydatetimeformat = 'Y-m-d H:i:s e';
    /**
     * 'Y' for year, 'm' for month, 'd' for date,
     * 'H' for hours, 'i' for minutes, 's' for seconds,
     * and 'e' for the timezone name
     */
    echo $mydatetime->format($mydatetimeformat),
      $mydatetime->format('I')?' DST':'';
  4. Perhaps you would like to see the date and time in another timezone? No problem, PHP has that covered.
    $mytimezone2 = new DateTimeZone('Asia/Tokyo');
    $mydatetime->setTimezone($mytimezone2);
    echo $mydatetime->format($mydatetimeformat),
      $mydatetime->format('I')?' DST':''; 

Word of caution

The constructor method of DateTime is supposed to return false on failure, so you may be under the impression that you can rely on it to validate date and time strings. For instance:

$montrealtimezone = new DateTimeZone('America/Montreal');
$bogustime =
  new DateTime('2007-03-11 02:30:00', $montrealtimezone);

The above snippet is supposed to result in $bogustime holding the value false because ‘02:30:00′ is not a valid time on that date due to Daylight Saving Time entering into effect. Unfortunately, the constructor does not catch the mistake and will return you a DateTime object representing March 11th, 2007, two-thirty in the morning, Montreal Daylight Saving Time. It is a bug that I recently discovered in PHP 5.2.0 and submitted to the php bug database. It does not seem to be fixed as of this writing, where the latest stable released version of PHP is 5.2.1. You can check the status of the bug here: http://bugs.php.net/?id=40340.

Edit:
A comment by Eric has prompted me to clarify that the above bug is NOT caused by an outdated zoneinfo database. You can test it by trying to instantiate a similarly bogus date of a past year, while having the most up-to-date zoneinfo database installed.

Solving grade 8 algebra… the Enterprise way

Thursday, June 1st, 2006

I have been tutoring grade 8 math for some time. And let me tell you that it is not easy. Doing grade 8 math is one thing, but tutoring/teaching it is a completely different story. The trouble is that, by dint of having done a lot of much harder math problems as a university graduate, high school math just seems to be second nature and it has become hard to recall or even explain the thinking process behind solving simple problems.

As someone who reads The Daily WTF religiously everyday, I thought I would be less likely to fall prey to Enterprise-hype. How wrong I am! Anyway, last week I pulled a Daily WTF while tutoring math to a girl. It turns out that I showed an Enterprise solution to a grade 8 algebra problem. Here it is:

Tommy’s father is 5 times as old as he is. His mother is 2 years younger than his father. Together, the sum of their ages is 75. How old is each of them?

Having dealt with multi-variable systems of linear equations for so long, my approach was “naturally” to identify the unknown variables and then to translate the sentences into equations:

T: Tommy;s age
F: the father’s age
M: the mother’s age

F = 5T
M = F - 2
T + F + M = 75

Now we do some substitutions:

M = 5T - 2
T + 5T + (5T - 2) = 75

Finally, we solve for T, F, and M:

11T - 2 = 75
11T = 77
T = 7
F = 5T = 5 * 7 = 35
M = F - 2 = 35 - 2 = 33

I thought that this method was already pretty dirty because I haven’t even put the equations into matrix form and used the more formal linear algebra methods that I learned in college (or even the Gauss-Seidel method).

Yesterday I was tutoring the girl again. This is the first thing she said as I took out my pencil, eraser, etc: “I asked my teacher about it and she said your method is completely wrong. She said that you are teaching me stuff that I am supposed to learn only next year so she doesn’t understand why you’re trying to confuse me.” I was pretty shocked and “pwned” was written all over my face. As it turns out, what the girl’s teacher has taught (and was thus expecting) was actually even dirtier:

Father’s age = 5x
Mother’s age = 5x - 2 (since we already know the father’s age is 5x)
Sum of the ages = 5x + (5x - 2) + x = 75 (since we already know the father’s age is 5x and the mother’s age is (5x - 2)
Therefore…
11x = 77 –> x = 7
Father’s age = 5 * 7 = 35
Mother’s age = 35 - 2 = 33

Notice that they don’t bother with things such as identifying variables or substitutions. The whole problem was solved pretty much using only 1 variable from start to end. The reduction in complexity and in number of steps is pretty amusing. I think it was a good lesson (for me).

Impresario Public Release

Monday, May 29th, 2006

It’s been decided. Impresario is scheduled for public release on June 1st. Among other cool new features, it will feature a setup wizard to facilitate deployment. I hope everybody will enjoy the release.

Impresario is not dead!

Thursday, May 4th, 2006

From the reactions we gathered at the capstone demo, it appears that many people like our product. Now here is a great news for those of you interested: the development of Impresario is entering phase 2! That’s right, even though we have already handed in the product for evaluation, we have decided that we are going to keep improving it.

The scheduling plug-in is the one of the first components that we will upgrade.


Bad Behavior has blocked 122 access attempts in the last 7 days.