Monday, July 27, 2009

interfaces deassembled

There are always requirements like a particular class is to be able to perform certain actions,these actions will lead to get some special characteristics of that class. normally these actions are generic in nature and if in any case that action is so specific to that class then this action is not a candidate of interface.what generic action we can think of?? suppose we are designing classes for a program of a traffic monitoring system, we have classes like , vehicle,twowheeler,fourwheeler,car,bike,signal_system and there can be many more..for these vehicle related classes some generic actions we can think are shiftgear(),applybreak(),reverse(),forward() and so on. now there are many programmers , each writing their code and using other's too, they need to use code written by each others,one may write car class, another programmer may write bike class , someone is writing main class, so we are convinced with the fact that each will need to inter-operate with others (after all that's the basic architecture of an object oriented software ie,collection of objects, each using services provided by others and giving services to others).

now if these generic actions are known are to a programmer, and somehow he knows that a class can perform these type of actions, then he wont need to know much about that class, he will simply call the method and get the things done(we suppose that the programmer is intending to use the class only for the generic actions).

now these generic actions are specified in a thing which we call an interface, and if a class is providing these actions then that class will announce that by having a syntax like this.

class myimp implements someinterface

{


}
and by doing this, the class is supposed to provide the actions which have been specified in the implemented interface.
now by seeing only this thing one will know that yes!! this class provides actions specified in the interface which it's implementing.so i am being guaranteed to have that behavior given by the class.
hence a protocol is set among classes and hence progrmmers to use functions,actions,methods(all being talked with the same meaning in mind!!) provided by others.

in the example given above a suitable interface w'd be

interface movable

{
void applybreak();
void reverse();
void shiftgear();
void moveforward();

}


we can see that these are very general kind of actions for vehicle related classes.

now the car class implements movable interface then it will provide implementation to those methods and hence some other person can easily call those methods.

class car implements movable

{
public void applybreak()
{

}

public void reverse()
{


}

public void shiftgear()
{


}

public void moveforward()
{


}

}

so in this way with the help of interfaces 1. a class can announce what things it can do and what's it like 2.a contract can be set among different programmers!!,so that they can easily and independently use classes written by each other for some generic type of behavior of that class.

Wednesday, April 1, 2009

An individual being is defined by St. Thomas as "quod est in se indivisum, ab aliis vero divisum" (a being undivided in itself but separated from other beings). It implies therefore unity and separateness or distinctness. Individuality in general may be defined or described as the property or collection of properties by which the individual possesses this unity and is separated off from other beings. What is it that constitutes an individual, or individuality?

so very clear from the definition, the unity of constituents of the self does guarantee uniqueness.only this phenomena is sufficient for the existence of an individual as a distinct individual.however,this is a very theoretical and assumptive way of putting this up.In practical world the individuality comes out a little more different than what has been perceived philosophically.The basic tendency of human mind(the only animal with conscious mind and ability of logical thinking )is to struggle endlessly in order to feel the distinctness and the uniqueness .First of all, i never understand why human mind starve for uniqueness, why it wants to prove that its very unique and like very rare to find.Human is a so called social animal,then why it doesn't accept to be the part of crowd??why it wants to be different?? why it finds a satisfaction and happiness in being different from others?I don't know the cause but the consequences are well apparent.and that is what the point of origin of all the problems.some people desperately keep on watching for flaws of others to feel that they are good because they don't have that flaw..taking all these points into one view , we can very clearly foresee one major problem of human life, and that is separatism.Now taking some practical examples...beware,these examples may seem very funny but they are quite real and meticulously observed

1. Some people feel they are unique because their choice is very unique.

2. some people feel happy when some others call them psychic, they enjoy it.

3. some enjoy doing awkward and unusual things(activities).

4. Few worship daily because they have associated their goodness to this one activity.

5. some feel different by their thoughts and philosophy

Now see the people around you , you will find at least 50% of them belong to at least one of the categories specified above.So these are some practical means of caring for individuality in today's world.The meaning is totally deviated from it's originality.The hunger of distinctness consequently and essentially gives birth to many recursive tendencies like impressionism, superiority complex, gruoupism and so on..Now solution is what?? Even i don't know, because i too belong to one of the categories, i believe that knowing and understanding the problem is itself the first step towards devising a solution to the problem..