Oct 17, 2009

How to prevent your OO program growing a GIANT INHERITANCE TREE

Object-Oriented programming is a paradigm for software engineers to seperate a computer program into discrete and reusable units, which are called "objects". One of its technique to resue the existing source codes is through "inheritance". That is, we find a common operation among objects, then we create a "parent class" to represent this operation.

"Inheitance" is an important technique to reuse source codes. However, we find it harmful in some cases.  One of download tools in our team faces suce a problem.
The functionality of the tool is to download binary images into the flash memory of a mobile phone. Since there are a wide range of mobile phones to support, the tool contains a lot of objects. Each objects represent a download process of a specific type of mobile phones. The problem is that the download processes are just slightly different with each other. One of the reasons why they are just slightly different is due to workarounds of hardware bugs. The "slightly different" codes then result in a tall and giant inheritance tree. Inheritance, generally, is a good technique. Nevertheless, when a object has too many ancestors, the operation of the object becomes obscure. The real implementation of a virtual function may be resided in any of the ancestors. It's hard to tell which one really takes effect from the source codes.

One of my colleagues wants to resolve this problem by refactoring the existing inheritance tree into a shorter one. He designs a common downloading procedure for all kinds of mobile phones. The procedure contains many but fixed steps, and each mobile can have its own step implementation if the its step is slighlty different than other mobiles phones. I am sure that he is going to succeed to reduce the height of the tree, but I doubt that he can prevent the tree from growing higher again.

The reason why he is going to succeed is primary because all of the workarounds of previous phones are known, so he can devise a download procedure general enough to cover all of the workarounds. On the other hand, the workarounds of future phones are impossible to known. When a workaround happens, it might break the existing download procedure and require to refactor the existing codes or increase the height of the tree. He said to me that the new download procedure is so general that it's impossible to break.

I think otherwise.

In the software world, it's better to have less assumptions on your source code. The less you assume, the less you will rewrite when the assumption fails. From my point of view, it's not necessary to assume that there is a one general download process which can cover all kinds of mobiles phones. Why not just assume that the download processes of mobile phones are all different. The reason why we want to find common procedures in our codes is because we want to reuse our codes. We don't want to copy and paste the same code in every place. If we do so, the code will be very hard to maintain since we need to change the same codes in many different places.

For the download tool, it's not the case. The download tool is basically a one-time programing. We write the code for a specific mobile phone. If it works, the coding is done. There are no more maintainence effort on the code. We just need a working code to download the binary images. That's all. For most of the time, it's very dangerous to refactor the source code of the download tool, because it might break the existing code and make the download tool fail on older mobiles. To prevent such problem, we need to perform a lot of regression tests. So it's even better if we don't maintain the code and leave the working code unchanged. If we want the inheritance tree shorter, we need to refactor our existing codes, which might break them. Alternatively, if we avoid inheritance and treat each download process as a seperate script, assume different mobile phones have different download process, we can get a clear program architecture. The program will be easier to read, because the download script shows all operations and workarounds it performs. It also avoid changing the existing codes and therefore it does not require the tedious process to test all old mobile phones.

Sound great. Now, please prove I am wrong

Oct 15, 2009

Panasonic Let's Note CF-Y8EWJAJR

Centrino(Santa Rosa)
CPU: L7800 @ 2.0GHz Merom
CPU voltage: 0.96V
Intruction: SSE3
L2: 4MB

Display: GM965 (X3100)
Sound: AD 1884
Wifi: Intel 4965AG
Net: Marvell Yukon 88E8055
SD card: Ricoh RL5C822
Cardbus: Ricoh RL5C476

台灣之光時尚精品捷安特City Speed

台北購物節展出的台灣精品中,得到精品金質獎的捷安特City Speed是唯一的工業設計作品。

這款城市公路車由英國設計師Michael Yang操刀,極簡的外觀融合科技感及創新性,除了獲得第十七屆的台灣精品金質獎外,它也得到2008年IF EUROBIKE設計獎城市車類金獎的殊榮。

IF EUROBIKE評審團給了這款車款極高的評價:
"The bike is very well designed from start to finish. All the components have been specially coordinated to work together perfectly. The front light, the stem and the handlebars, for example, from a single unit. Great."



外觀極簡,前後車燈都整合在龍頭及座管上,鋁合金車架,有2款,City Speed平把20速售價43800元,City Speed i8內變8段變速售價39800元。

在台北購物節新光三越信義店A11展出的是City Speed平把20速。



Oct 13, 2009

The Greatest Nobody

As a nobody, I have a special interest in studying other nobody's life stories. Through their stories, I can learn more about the humanity, the society, and the possible endings of a nobody. I am always wondering, what a nobody can do in his/her negligible and pitiful life.

The definition of a nobody is simple:
1. His parents are not rich.
2. His look is not good.  (i.e. no handsome boys)
3. He is not smart.
4. He is located at the bottom of a social hierachy.

The first nobody comes into my mind is Michael Faraday.
His father was a blacksmith. His brother was a blacksmith. So what could he do?

The second nobody is Marie Curi.
Her family lost every property in a historical event. Her country was occupied by Russia. She hardly kept her life going in a nothing-left research facility.

The thrid nobody is Nikola Tesla.
He was too poor to pay tuition fees of the university. As a serbe, surely did he locate in the bottom of the society. In fact, serbes in 19th is equal to slaves. 

The last one is Albert Einstein.
Everyone around him thought he was a nobody. Indeed, he was a nobody. As a PhD, he could not get any teaching positions in universities. Finally, he got a work in a patent office, which is a significant failure in his career.

As a noboby, I feel I am more fortunate than the above nobodies.
My family has some properties. My career is more successful. My country is still alive.
Nevertheless, these nobodies are the greatest in human history. They made significant contribution to the human society despite the fact that the society had abandoned them before.

Could I do the same?

The Norns

Shortly after my girl friend went to USA, the Norns started to appear in my mind once in a while. I feel something is going to happen, but I don't know what it is.

They appeared in my mind in this way:

Strange enough, they are not girls, but a Wing Gundam(飛翼零式特裝型).
It didn't take me too much time to find this image on the Internet. It exaclty matched what I saw  in my mind. Wait...I am not a Gundam fan. Where did I see this?

I need a psychologist.