Reality is a perception. Perceptions are not always based on facts, and are strongly influenced by illusions. Inquisitiveness is hence indispensable

Tuesday, March 20, 2007

vaio why?

Sumit left for Japan last week. He isnt' quite completely settled, but he is not a new customer. Hes been to Japan before too. Yesterday, he mailed ashish & me asking for an opinion about laptop purchase. He has already made up his mind and is giving a serious thought towards VAIO. Apple is off the radar, DELL is still within proximity range. His requirements are quite amusing. Till date I have seen guys boasting about their CPU muscle power! and enormity of memory space. This is the first time I have seen a techie someone go after really after a stylish glam doll. Ever heard of Armanis and RollsRoyce among computers, VAIO quite in the same league. VAIO has an interesting logo too. A cosine wave followed by 1 & 0 (binary notation). What does that mean? Pretty rudimentary isnt' it? Do most owners understand the significance of the symbol or is it... AAh I must be day dreaming.

Monday, March 12, 2007

Festival of colors

First things first, I am blogging this albeit late. Holi, in INDIA is also called as festival of colors. It falls in the early spring season. The colors are vibrant, so is the mood. Boys and girls have a go at each other with colors. It commemorates the ancient epic of Holica, sister of Hiranyakasipa who had a boon of being untouched by fire, being killed by Lord Vishnu when she intends to hurt his disciple Prahlad.

Children make merry throwing water balloons and spraying colors at every one. This festival is also memorialized in Raasa Leela, where Lord Krishna celebrates Holi. This year we had a gr8 time. First I was dragged into muddy pool then had colors hurled at me. Then had a chance to repeat the same unto others and finally in the afternoon went to a rain dance and danced for a long time. The colors was completely washed away by the end of the evening and I wasn’t’ sorry for that.

This is one day that stays long in memory

Yahoo! sounds

Last week I checked web for voice offerings. I was looking for cheap and reliable voice based offering. Guess what! I found that Yahoo has the best offering, I can call USA for just 1 cent per min. I had to pay 10$ for this and I have got atleast 1000min of talk time. Luckily I have a good net connection and I brag about the same :)

Skype comes close but at 2 cents per min they made my decision easier. You all know where my 2 cents went, don't' you.

Monday, March 5, 2007

The static thing

The way we think reflects what we want to achieve. Humans are inherently comfortable thinking in terms of objects. It is rather strange that I was taught structural programming than an object oriented one, earlier in my academics. I am not going to speak in detail about OOPS, but concentrate on one aspect of the OOP Languages. Usage of "static".

As a norm, object-orientation avoids unnecessary "static" declarations, any entity carrying a "static" tag needs scrutiny and the relevance of static-ness needs to be questioned. This doesn’t' mean that static needs to be strictly avoided. It should be used as per the requirement.

Question : Let us think of a MVC style program where model and view are seperated. The hierarchy of model is "GenericModel", "SpecificModel" which extends "GenericModel". For simplicity let us alias them as GM and SM. GM and SM also have attributes defined within them. Not very different from other classes you may say. Now here is the catch, What if those attributes are "static" and are to be inherited. Design an object oriented specification for the above. On the face of it, the problem is obscure. So let me elaborate.
Static nature : A brief intro on static nature. Static entities are tied up to class definition rather than objects’. So static entries are accessed using class context, rather than object context. In such a case the concept of Runtime polymorphism is irrelevant and hence for static entries, the super class definitions and references take precedence over derived class ones, i.e. if GM has attr ‘x’ and SM also has another attr’ ‘x of the same type;
GM o1 = new GM();
GM o2 = new SM();
Print(o1.x);
Print(o2.x); // value printed here is same as that in above line.

You might have already observed the oddness. Most design patterns essentially rely on the fact that interfaces are available (abstraction) and use runtime polymorphism to do the trick. The situation here is different; the super class reference determines the value one gets.

Problem version1: We had two classes called "ModelElement" and "ObjectModel", the later extending the former. “ModelElement” class was contributing an attribute called "Name" and ”ObjectModel” was contributing an attribute called "Classifier". Now we have a GUI for the properties represented by an element. All instances of the “ModelElement” are supposed to have a view like “Name :: ”, and all entities represented by “ObjectModel” are supposed to have a view similar to above and in addition contribute its own “Classifier :: ”. Clearly “Name” and “Classifier” can be logically concluded to be static.

Now the complete version: We have number of attributes to be contributed rather than one per class. So we use vectors for holding all attributes in the vector and return it.

Solution 1: Not a solution, but for discussion. As this is one possibility we run into. Make the vector in super class Model protected static. This will fail for all the cases where derived class is instantiated before super class. The vector gets filled with attributes of both derived a super and when we later want attributes specific to super class it fails to do so.

Solution 2: Create a static vector in every derived class. Also, create a non static method to return this vector in every derived class. Use super. invocation to call super class method. The polymorphic behavior calls the hierarchy of classes and returns a vector of appropriate entities.Problem with this approach: Imagine a huge hierarchy, if some class in the hierarchy doesn’t’ override this method properly with super invocation; the returned values may be drastically different.

Solution 3: Use singletons to represent objects. Now inheritance among singletons is another over head. Think of the possible cases. Singleton entities may themselves be part of some other hierarchy and what about issues with Multiple Inheritance in singletons?

Solution 4: Using reflection, identify the static entities defined in the class hierarchy and return them to the user. Problem is that this approach is possible only in languages with support for reflection. This involves certain amount of hard coding of method/attribute names.

Clearly no solution described above sufficiently addresses the current concerns, If you have a cleaner solution to handle above, please feel free to mail me.

My First Post

It is believed that Voltaire once said, "I may not agree with what you say, but I'd fight for your right to say - what you want to say".

I never thought I’d’ve a blog of mine before. In a very voltairish way, I used to enjoy reading blogs of near and dear. But, why a blog? Probably its my urge to pen my thoughts, or probably to have something to be nostalgic later on... There may be zillions of reasons, as many as the value of Avagadros' number. For me what matters most is my ability to recap my thought currents, the questions and more importantly the intriguing aspect of human psyche to keep itself intrigued.

Popular Posts

Labels

About Me

Well for a start, I dont' want to!. Yes I am reclusive, no I am not secretive; Candid? Yes; Aspergers? No :). My friends call me an enthusiast, my boss calls me purist, I call myself an explorer, to summarise; just an inquisitive child who didnt'learn to take things for granted. For the sake of living, I work as a S/W engineer. If you dont' know what it means, turn back right now.