My blog has been moved to

Wednesday, August 29, 2007

Legacy vs Lateral (3): Solution space isn't always in two dimensions

This one also happens not so seldom.

Supervisor: Hey, can you do Visual Basic?
Developer: (surprised) Ahm, it depends....
S: Look, I finally got the library that we need for our development. It comes with lots of VB examples, so please integrate a VB module with our app.
D: Could you send me that stuff first?
S: Sure.

Few minutes later, the "stuff" has been received by the developer. After carefully examined it for few minutes, our hero found out that it's just a normal dynamic library, it can be loaded by standard mechanism that every experienced programmer (worth his salt) is familiar with. The VB thing is just because examples are given for VB, presumably to show how easy it can be. But it is not necessary to restrict the solution space to VB.

Setting aside VB & friends, what is important is the concern: often, you are already given a (very) limited set of solutions for a given problem. Long long time ago, that may work well. But nowadays, it won't be that easy. Systems become exponentially more complex, our brain is bombarded with lots of useful information as well as useless junks, there are A to Z details that the brain cells won't bother anymore. It becomes very challenging to be able to have an overview, let alone to always play the polymath rule all time. And the devil is always in the details.

Share the problem descriptions, not always the proposed solutions. And thus, triggers creative thinking and discussions.

Super Funny Mario

(Found via

Tuesday, August 21, 2007

Linus on git (again)

(No, this isn't about the Linus' Tech Talk video on git).

The nice thing working on KDE project is because Linus likes KDE. Thus, it is not (so) surprising (he used to help with bugs, e.g. #27340) to see Linus himself writing something (read: sending some "enlightment") to kde-core-devel, again on the topic of git:

Centralized _works_. It's just *inferior*.

I'd like to see a ThinkGeek shirt with that quote.

Sunday, August 19, 2007


One word: it rocks!

(Well, that's more than one, but you get the idea...)

Saturday, August 18, 2007


Who is going to pay almost $500 for a phone?

Browser: Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C25 Safari/419.3

(A comment to the $491 Linux-based Motorola RAZR V8, posted from an iPhone).

Thursday, August 16, 2007

Legacy vs Lateral (2): Design for the future, not for today

Did you ever try to assemble and create a great product but lately much more better, powerful and yet cheaper components are suddenly available, and were they available sooner, your life would have been significantly simplified? Setting aside first that nobody can really predict the future, it is important here to emphasize that often - but not always [1] - it makes more sense to design something for tomorrow or next year, rather than just for today.

The classic example for this is game development. Unless you're coding a simple Pong clone, the whole process of game development (think the upcoming id's Rage or Crytek's Crysis - but certainly not Duke Nukem Forever) can take ages. By the time the game is finished, the whole digital world already makes a few leaps here and there. Thus, it is absolutely necessary to predict the trend and ride the curves so that the shipped game will match the available technology and cover the intended market as it may completely change many design decisions during the development phase.

For the sake of giving an example (I'm not saying this is what's going to really happen), say you're 1000% absolutely sure that Physics Processing Unit card ala Ageia would be ubiquitous in platforms you're targeting, just like today's accelerated graphics chip, then it will be less sensible [2] to use physics engine which won't take advantage of the said unit, let alone optimize it to death, because right after you launch the game, it might have hard-time competing with other games which are e.g. specifically designed to exploit the physics processor.

The same goes for any non-trivial things that needs engineering love. We're not in the 70's anymore, a satisfactory achievement needs more than just a weekend, a copy of Popular Electronics, a bunch of vacuum tubes, plus a TV [3].

But the real challenge remains: how can you convince your superior that it's the right thing to do?

[1] For example, if your software is supposed to work well even on old systems
[2] There are of course obvious exceptions to this, e.g. you don't need fancy graphics nor physics
[3] Like a project to show the actual time at the corner of the TV screen

Postscript: To avoid misunderstanding, it does not mean that things like software bloatness is endorsed. Quite contrary, because bloatness is typically caused by careless uses of system resources and superfluous features while design for today implies imposing restrictions (which will not exist anymore in the future) unnecessarily. Between these two extremes we must stand.

Tracing the diagonals

This is a real-world problem, but could also serve well as an interview question. The task is to create two sequences of numbers which when plotted against each other (ala Lissajous curve) give the following (the knots are there to emphasize the points):

Here was my quick hack to solve it (written for Qt 4.x). The important part is in the constructor, the rest is only to show the result. I'm sure there are way better and much more elegant solutions. Care to share yours?

#define NSIZE 5 // must be odd

#include <QApplication>
#include <QPainter>
#include <QPainterPath>
#include <QWidget>

class W: public QWidget
  int* x;
  int* y;
  W(): QWidget(0)
    x = new int[NSIZE*NSIZE];
    y = new int[NSIZE*NSIZE];
    x[0] = y[0] = 0;
    int xs = 1, ys = 0;
    for(int i = 1; i < NSIZE*NSIZE; i++)
      x[i] = x[i-1] + xs;
      y[i] = y[i-1] + ys;
      xs = (x[i]-x[i-1]+y[i]-y[i-1] == 1) ?
           (xs) ? (y[i] ? 1 : -1) : (x[i] ? -1 : 1) :
           (!x[i] || x[i]==NSIZE-1) ? 0 :
           (y[i]==NSIZE-1) ? 1 : xs;
      ys = (x[i]-x[i-1]+y[i]-y[i-1] == 1) ?
           (ys) ? (x[i] ? 1 : -1) : (y[i] ? -1 : 1) :
           (x[i]==NSIZE-1) ? 1 :
           (!y[i] || y[i]==NSIZE-1) ? 0 : ys;

    delete [] x;
    delete [] y;

  #define DD 0.05
  void paintEvent(QPaintEvent*)
    QPainterPath d;
    for(int i = 0; i < NSIZE*NSIZE; i++)
      d.lineTo(x[i], y[i]);
      d.lineTo(x[i]+DD, y[i]+DD);
      d.lineTo(x[i]+DD, y[i]-DD);
      d.lineTo(x[i]-DD, y[i]-DD);
      d.lineTo(x[i]-DD, y[i]+DD);
      d.lineTo(x[i]+DD, y[i]+DD);
      d.lineTo(x[i], y[i]);

    QPainter p(this);
    p.fillRect(rect(), Qt::white);
    p.setPen(QPen(Qt::red, DD));
    p.translate(10, 10);
    p.scale((width()-20)/(NSIZE-1), (height()-20)/(NSIZE-1));

int main( int argc, char ** argv )
  QApplication a( argc, argv );

  W* w = new W;
  w->setWindowTitle("Diagonal Tracing");

  a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );
  return a.exec();

Wednesday, August 15, 2007

Legacy vs Lateral (1): Google is here to help

Did you ever experience the typical scenario like this before?

The phone rings.
Engineer 1: Yes?
Engineer 2: Hi, it's me. Look, I have a problem here with my <insert-your-favorite-CAD-application>. Can you help me?
E1: Fine, I'll come over.

Few minutes later.
E1: So, what kind of problem do you have?
E2: I'm trying to run this-and-that. And out of sudden, what I've got is the following error message: bla...bla..bla..
E1: Hmm, that's strange (thinking for a minute or two).
E2: Yeah, that's not supposed to happen, isn't it?
E1: Did you google already?
E2: Google..what? Ah, I see. No, I didn't try googling for that problem...
E1: Well, let's try it now.

And after 5 minutes of googling and flipping web pages, the problem was easily solved. As a matter of fact, it could have been solved earlier.

Although it looks simple, the above scene happens quite a lot. Those who grow up in the late nineties and take for granted that Internet exists for their conveniences often quickly open whenever they find a problem (even as far as replacing the pocket calculator) and most of the time just mechanically and without too much thinking. Whether it's about using Google or other search engines, searching for some support articles, or even reading discussion archives, the idea is the same: let's tap into the vast amount of knowledge available out there. Given enough brains, likely one of them solved the problem already. However, the previous generations (granted, not all of them of course) sometimes struggle with this concept of "information at your fingertip".

Ever witnessed something similar?

Tuesday, August 07, 2007

Three Envelopes

A fellow had just been hired as the new CEO of a large high tech corporation. The CEO who was stepping down met with him privately and presented him with three numbered envelopes. "Open these if you run up against a problem you don't think you can solve," he said.

Well, things went along pretty smoothly, but six months later, sales took a downturn and he was really catching a lot of heat. About at his wit's end, he remembered the envelopes. He went to his drawer and took out the first envelope. The message read, "Blame your predecessor."

The new CEO called a press conference and tactfully laid the blame at the feet of the previous CEO. Satisfied with his comments, the press -- and Wall Street - responded positively, sales began to pick up and the problem was soon behind him.

About a year later, the company was again experiencing a slight dip in sales, combined with serious product problems. Having learned from his previous experience, the CEO quickly opened the second envelope. The message read, "Reorganize." This he did, and the company quickly rebounded.

After several consecutive profitable quarters, the company once again fell on difficult times. The CEO went to his office, closed the door and opened the third envelope.

The message said, "Prepare three envelopes."