Prev - DUP - Next - TOC

Introduction to object orientedness


"Object oriented" is a trend word. "Object oriented" anything sounds smart. Ruby is also "an object oriented scripting language". Well, to begin with, what does "object oriented" mean?

It seems that defining OO causes arguments among even experts, probably, so everyone has slightly different difinitions. Although if we are bothered with those differences we can't start talking, so a bold definition is given here. "object oriented-ness" is a style of taking a point of view, (what is called `paradigm'), in short,

    a point of view centered on objects. 

It is too short to understand, so let's compare it with the traditionally fashioned point of view.

According to a traditionally fashioned point of view in terms of computers, one might have considered problems to solve as something should find the combination of `data' and `procedure' for them.

For example, one gives "an allowance data" to "a procedure calculating allowance", then one will get how much I earn this month. This may be written programically as follows.

    salary_of_this_month = allowance_function( allowance_data_of_matz )

If when one in the accounting department calculates my salary that person uses the allowance_data of my boss to allowance_function in a mistake for mine, my salary might be increased (and someone would chew out the accountant :-).

On the other hand, according to object oriented thinking, problems are considered through `objects' and their `interactions'. For example, the above case, an object `allowance ledger' manages the data of basic salary. In an object oriented way, an object is not a simple object but is smart enough to answer various questions. To get how much my salary is this month, one may ask the ledger object, `How much is matz's salary this month?'. Then the ledger object will give an answer based on the result of calculations of internal data. This is sketched as follows.

    salary_of_this_month = salary_ledger.salary( this_month, matz )

In this way, basic statement "asking salary_ledger" will not be changed if the internal or external way to calcutate salary (e.g., data structure, or matz's position) will be changed in the future.

You may or may not understood the above; Any explanations are given so always, for an invisible thing just as the sort of paradigm.

Though `a point of view with object centered' has these merits.

But note the above merit doesn't work in all cases. Well, any tool works "if you use it efficiently", as you know. Object oriented thinking is not a cure-all; wrong use causes troubles.

Ok, the explanation in general is completed. See the proper books for more explanation. I wish to recomend the suitable books if they might be in my mind. Any subjects may so; In the case of the books about object orientedness, a precise one is difficult, but an easy one tells unsuitable or wrong things sometimes. sigh...

Well, to return to our subject, as ruby has a title `an interpreted scripting language for quick and easy object-oriented programming', it has many convenient features for object-oriented programming. We will introduce them in a number of continued chapters.


Prev - DUP - Next - TOC