Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

What is object orientation? And how is it significant?

Object Oriented Approach

What is object orientation? And how is it significant?

by  umn  Posted    (Edited  )


What is, after all, object orientation?


Have you ever asked a five year old to explain what he saw after his first visit to the zoo?

"I saw monkeys!"

"What is a monkey?", you act ignorant.

"It is an animal somewhat like you. But it has long hands and long legs. Yes... got a long tail...big mouth and round eyes."

"And what more?", you are curious.

"Well... it grins funnily... it ties its legs on the bar and hangs upside down and swings! Jumps from one corner of the cage to another...And when I showed him a pack of peanuts, he snatched it from me!"

"And was there only one monkey?"

"No, there were three. One was a brown one... and then a short one. Uncle told me it's the brownie's son. Then in another cage, I saw a huge one, covered all over with thick black hair"
_________________________________________________________

Well, the little kid has explained you what object orientation is.

Consider a monkey as a type of object. You can see that:

[OL]
[LI]there are visible attributes for the monkey - long hands, legs, long tail, big mouth, round eyes[/LI]

[LI]there are attributes that are not visible- can you see the heart and intestines of the monkey? [/LI]

[LI]there are actions that it performs using one or more of the above attributes: grinning, hanging, swinging, jumping...these actions are visible outside.[/LI]

[LI]There could be actions not externally visible (realize that many muscles should move so as to enable the limbs - and these are not seen outside) [/LI]

[LI]there are different monkeys - the brownie, the little one, the huge black one. But they have the fundamental property that they are monkeys. [/LI]

[LI]chimpanzee is one variety of monkeys . All chimpanzees have big torso, thick black hair coat, they stand and walk like humans. Similarly, there are lion-tailed macaques - black but not so hairy, has tails similar to a lion...[/LI]

[LI]every monkey stays in a shelter. But the manner in which each one stay coiuld be different. Chimpanzees may crawl into caves, macaques may climb up and prefer tree tops. (I hope so!) [/LI]

[/OL]

So, the little kid has explained you the way he observed the monkey- through its attributes and actions. He does not know how the monkey manages to jump. He does not know what makes it snatch the peanuts. Without knowing all these, he can happily explain to you, and you are able to understand.

This is the idea of object orientation and classes.

[UL]
[LI]A class is a set of attributes and actions (also called methods or operations) on those attributes.The attributes may be public (see item 1 above) or private (item 2). The actions again could be public (item 3) or private (item 4). This is the concept of abstraction in Object Oriented approach. [/LI]

[LI]There can be many instances of the class, that has the same attributes and methods (item 5). [/LI]

[LI]You can derive a class from another. They have the same the same attributes and methods as the base class, but you can define additional attributes and methods - this is called specialization (item 6) and is nothing but inheritance.[/LI]

[LI]And you also see that the same action may be implemented in different ways in the derived classes. This is called polymorphism.(item 7).[/LI]
[/UL]

Now, why is it significant?


The Object Oriented approach speeds the design and development of new programs. Systematic use of this idea can result in lesser maintenance. Reusability of software artifacts is another major plus. Also, it is easier to modify and enhance software without affecting other modules in the application.

More about this, in another FAQ.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)
Back
Top