Ada and Multiple Inheritance

July 28th, 2011 at 5:24 · Filed Under Ada, At Work, Call Me a Geek, Days in My Life, Software Development · Comment 

When developing an information system which computes real-life data, one of the most common problems a software developer may encounter is multiple inheritance. Inheritance is one of the four aspects in Object-Oriented Programming (OOP).

What is Object-Oriented?

Object-oriented technique organizes software as collection of discrete objects incorporate with data structures and behaviors. Take a software that keeps records of professors and students in a university for instance. Both professor and student are person. These three entities – professor, student and person are objects. A person has data structure such as name, gender and date of birth to make things simple. Both professor and student share the same data structure of person. A professor has employee number, salary, and room number. And a student has student number, courses and grades. Both professor and student have different behavior: to lecture and to learn respectively. We can let professor and student to inherit the same data structure and behavior from person. Person is superclass. Both professor and student are subclass. Now both professor and student can derive data structure and behavior from superclass person but at the same time, both can preserve their own data structure and behavior as professor and student respectively.

Multiple inheritance is where a subclass inherits from more than one super class. One of the most common problems with multiple inheritance is symmetry. Let subclass D inherits from superclasses B and C which inherit from another superclass A. This is called symmetric multiple inheritance.

Multiple inheritance is rather problematic at linguistic level. Many object-oriented programming languages support multiple inheritance and solve the problems in such a way that usually they cause surprises to their users. In the above example, the operations in A can be derived to B and C and overridden in any other ways by any one of them in D.

Ada provides different approach to implement multiple inheritance by simply not allowing user to get into such problem in the first place and to force the user to break the symmetry.

While I slip deeper into my software design, symmetric multiple inheritance occurs. I have two classes A and B where both of them inherit from object List.Node. Another subclass C inherits both superclass A and B. Ada forces me to break the symmetry by letting C to have a direct inheritance from A plus indirect secondary inheritance of B.


package List is
   type List is limited private;
   type Access_List is access List;

   type Node is tagged private;
   type Access_Node is access all Node'Class;

private

   type Node is tagged record
      Previous : Access_Node;
      Next       : Access_Node;
   end record;

   type List is limited record
      Head    : Access_Node := null;
      Tail       : Access_Node := null;
      Current : Access_Node := null;
      Count   : Unsigned := 0;
   end record;
end List;

   type A is new List.Node with private;

private

   type A is new List.Node with
      record
         Id   : Integer;
         Str  : String ( 1 .. 20 ) ;
      end record;

   type B is new List.Node with private;

private

   type B is new List.Node with
      record
         Precision : Float;
      end record;

   type C is new A with private;

private

   type C is new A with
      record
         Magic : B;
         Plate   : Integer;
      end record;

Deadly techniques of Uechiryu

July 26th, 2011 at 23:08 · Filed Under Karate, Kata and Bunkai, Martial Arts, Training Journal · Comment 

I have not been writing about martial arts (especially karate) for a very long time. But that does not mean I have stopped practicing. Life has been busy with works lately and today my “mood” suddenly revisits me and so I decide to write this post.

Many of you may be wondering what I have been up to in karate. Have I stopped training? Hell no. I have been reading a lot about human anatomy and meridian pressure points these days. I find them enlightening. I became interested in human anatomy after working on a project building a gynecology website.

Using the knowledge that I have learned about human anatomy, many questions about Uechiryu techniques have been answered. These techniques are extremely dangerous and deadly when applied with medical knowledge.

What it is left now is training and more training to attain surgical precision strike in applying these techniques.

Bersih 2.0: The truth that cannot be covered

July 11th, 2011 at 22:52 · Filed Under Humanity, Kuala Lumpur, Malaysia, Politics, Social · Comment 

Which is the truth? The government of Malaysia has his own stories. The people of Malaysia who took part in the Bersih 2.0 rally last Saturday (July 9, 2011) have their own stories as well. True, not true. True, not true?

If you are in doubt of Bersih 2.0, please check out their website at http://bersih.org.
I am not going to write a long post here. The video below speaks louder than any words on earth.

Please watch the video carefully until the end then tell me which is the truth. If you have the slightest conscience, I am sure you will cry. I cried after watching the video and there is nothing shameful to tell everyone that I cried.

Fortunately, the man in the video who collapsed into unconsciousness has survived. Another man named Baharuddin Ahmad who was at KLCC during the rally, however, collapsed and died after being suffocated by the tear gas which was fired directly at his group by the FRU. A man has sacrificed his life while battling against the brutality of police and the tyranny of his own government.

Whilst one man is down, many thousands will rise for him!

 

Bersih 2.0 Worldwide

July 11th, 2011 at 15:35 · Filed Under Kuala Lumpur, Malaysia, Politics, Social · Comment 

I shed tears while watching this video. This is so damn touching.

Bersih 2.0: The ancient Chinese philosophy

July 10th, 2011 at 21:54 · Filed Under Chinese, Kuala Lumpur, Malaysia, Philosophy, Politics · 1 Comment 

Not long after Datuk Seri Najib Tun Razak became our prime minister on April 3, 2009, he made a four-day official visit to China from June 2 to 5 the same year. During the visit, he mentioned his father’s special relationship with China. His father, Abdul Razak, was Malaysia’s 2nd prime minister and first established diplomatic relationship with China in 1974.

Recently, before the Bersih 2.0 rally, he and his son Nor Ashman took part in a radio interview on One FM Morning Kaki program. Ashman greeted in Mandarin and the Prime Minister greeted in Cantonese.

One can easily tell that our Prime Minister is trying to impress the Chinese Malaysians how he embraces China, her language and her culture. That’s a good gesture of course. Unfortunately, the Bersih 2.0 rally which took place in Kuala Lumpur yesterday (July 9, 2011) has discredited what he has been portraying thus far.

You see, the Chinese language is not something that can be learned in a few months’ time or a few visits to China. It certainly cannot be learned using Google Translate or any other language translator on the Internet.

If our Prime Minister had studied and understood the Chinese wisdom below, what  happened yesterday would not have happened. Managing and ruling a country is not as simple as “早晨,大家好,我系Najib。” (Good morning, how is everyone? I am Najib).

Lastly, this applies to those MCA eunuchs as well. Being Chinese descendants and speaking Mandarin as your mother tongue means little or next to nothing in embracing the Chinese culture. Your mentality is only equivalent to that of the uneducated peasants in the society in ancient China.

不 尚 賢 , 使 民 不 爭。
不 貴 難 得 之 貨 , 使 民 不 為 盜 。
不 見 可 欲 , 使 民 心 不 亂 。
是 以 聖 人 之 治 ,
虛 其 心 ,
實 其 腹 ,
弱 其 志 ,
強 其 骨 。
常 使 民 無 知 無 欲 。
使 夫 智 者 不 敢 為 也 。
為 無 為 , 則 無 不 治 。

Bersih 2.0 – Love to my country

July 9th, 2011 at 23:05 · Filed Under Blogging, Critiques, Days in My Life, Kuala Lumpur, Malacca, Malaysia, Politics, Social · Comment 

Today, July 9, 2011 is the day tens of thousands of Bersih 2.0 supporters marched in Kuala Lumpur peacefully for the good cause to seek electoral reform for a clean and fair election. There are plenty of information spreading on the Internet about Bersih 2.0 rally so I am not going to repeat everything here.

One thing for sure, this rally has changed my perception and the spirit of a true Malaysia, where all races – Malays, Indians and Chinese united under one cause despite of the unwarranted, tyrannical acts by the National Front government and the police. I have never felt more proud of being a Malaysian.

A quote from a friend of mine from Hong Kong:

Democracy won’t come to you, is you go and get it. if you have chance just speak out loud, or shout from the rooftop. – Atropos

And from famous actor Clint Eastwood

Sometimes if you want to see a change for the better, you have to take things into your own hands. – Clint Eastwood

What happened today on July 9, 2011 will be written in the history of Malaysia. This is the day when fellow Malaysians stood up bravely to defend their civil liberties which have long been disrespected by the ruling government since independence. I don’t want my children, when they grow up, ask me: “Dad, what had you done on July 9, 2011?” and I can’t answer them. So I decided to wear yellow (the signature color of Bersih) and walked in town to show support. Honestly, as a father of three and the breadwinner for my family, such decision was not without fear. Why fear you may ask? Perhaps Malaysia is the only region in the world where you can be arrested for merely wearing yellow. And being arrested is one thing, how you would be treated after arrest is another.

This morning, I wore a yellow T-shirt and moved around at certain parts of the town. In the afternoon, after meeting my client at his office, I walked from Hatten Square, crossed the main road, and walked length of Dataran Pahlawan in the same T-shirt.

Having been following up the rally happenings in Kuala Lumpur since morning, I thought I could at least feel a little of the Bersih atmosphere here in Melaka. Disappointedly, I only saw large crowds, mostly Chinese, hanging out at Hatten Square and Dataran Pahlawan happily as usual. Everyone seemed carefree and undisturbed by the fact that thousands of people were being treated inhumanly by the police just because they wanted to ask for a clean democracy for all Malaysians. I hardly spotted one that wore yellow. If you look at the photos taken during the Bersih rally, you can see most of the protestors are Malays, relatively few Chinese took part in the rally. I am not being racist here, my point is there are too many Chinese Malaysians who simply don’t give a damn to the wellbeing of the country. They don’t even care to vote. All they care about are how much money they can make and how well they can live. With such attitudes, no wonder the Chinese are being called “pendatang” or squatters in spite of the fact that they are born in Malaysia. I think these people really deserve such labeling.

Although what I did was insignificant and actually nothing compared to those who had risked being arrested, injured or even losing their life to join the Bersih 2.0 movement in Kuala Lumpur today, I am glad that I have made one tiny step to conquer my fear by wearing yellow and walking on busy road and in busy malls in the heart of Melaka, with the spirit of Bersih (Clean).

If you want to conquer fear, don’t sit home and think about it. Go out and get busy. – Dale Carnegie