Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
OOP Article Jan 08

OOP Article Jan 08

Ratings: (0)|Views: 610|Likes:
Published by sgganesh
see www.joyofprogramming.com
see www.joyofprogramming.com

More info:

Published by: sgganesh on Jun 02, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/20/2010

pdf

text

original

 
98
JANUARY 2008
|
LINUX FOR YOU
|
 www.linuxforu.com
C M YK
Insight
On the Notion of
Object-OrientedProgramming
This article discusses the fundamentals of object orientation, and in the process dispelssome myths about it.
 
Insight
98
JANUARY 2008
|
LINUX FOR YOU
|
www.linuxforu.com
C M YK
 
www.linuxforu.com
|
LINUX FOR YOU
|
JANUARY 2008
C M YK
99
Insight
bject-orientedprogFramming (OOP)has been the mostpopular programmingparadigm for more thantwo decades and has been thesubject of active research for quitesome time now.With such widespread use, wewould expect the essence or basictenets of OOP to be widely knownto students and practitioners.However, the essentials are notoften understood or followed well inpractice. By just programming in anobject-oriented language does notnecessarily mean that we do thattask well. In this article we will lookat the fundamentals of objectorientation and try to understandwhy it has become so successful.We’ll also dispel some myths andface some hard facts about OOPtechnology.
The basics
What is object-orientedprogramming? HanspeterMossenbock’s
Object-Oriented Programming in Oberon-2
[Springer-Verlag, 1993] provides thefollowing definition: “Object-oriented programming meansprogramming with abstract datatypes (classes) using inheritanceand dynamic binding.” This makes itclear that OOP is about using ADTswith inheritance and virtualfunctions.Many of the attributes weoften associate with OOP aren’tinherently associated with thisdefinition. Strictly speaking,having a common base class (say,the object class), or languagefeatures like namespaces,exception handling, RTTI (RunTimeType Identification), reflection,operator overloading, functionoverloading, etc, are nothing to dowith OOP, as such. However, manymodern OOP languages (like Java)have a lot of these features, whichdoesn’t mean they arecharacteristics of object orientationitself. A language can have none of these features and still can beconsidered as a good OO language.
An example of flawedarguments
I recently heard the followingargument: “Java is better than C++because Java is a ‘pure’ object-oriented language. Java allows noglobal variables, it has a commonObject base class, and it does notsupport multiple inheritance and soon. But C++ is a bad object-orientedlanguage because it supportsprocedural programs, has nocommon base class, supportsmultiple inheritance, etc.”I like both Java and C++, butthat aside, let us analyse why thisargument is inherently flawed.Just because we believe that Javais a ‘pure’ OO language, it need notbe better than C++. Why is ‘pure’object-orientation better than anyother approach (like the multi-paradigm approach in C++)? Whatare the criteria for concludingwhether a language is ‘pure’ or‘impure’? Doesn’t Java’s supportof C-style conditional and loopingconstructs, and primitive typesmake it ‘impure’? Just because alanguage also supports otherparadigms doesn’t mean that it is abad OO language.Providing a common base class isa design decision that a languagedesigner makes in an OO language.Based on information and categorytheories, many researchers havesupported the argument that havinga common class as a base class for allthe classes is unnatural and a non-intuitive design.Inheritance is one of thefundamental features of OOP. Alanguage without any form of inheritance support cannot claim tobe an OOP language. Multipleinheritance is just one kind of inheritance and it is common to seeit in use (for example, a two-in-oneset inherits the properties of both atape-recorder and a radio).Practically, it is difficult to usemultiple inheritance correctly, and
O
the problems that may needmultiple inheritance can berewritten using only singleinheritance (possibly with somedifficulty). Because of suchreasons, a language designer canmake a design decision to supportor not support multiple inheritancein her language. However, justbecause an OO language supportsmultiple inheritance we cannotlabel it as a ‘bad’ language. As Paul Weiss wiselycommented: “It’s one thing not tosee the forest for the trees, butthen to go on to deny the reality of the forest is a more seriousmatter.”
Characteristics and benefits
OOP is based on the solidfoundation provided by theconcepts of inheritance,polymorphism, abstraction andencapsulation. An abstract data type providesus with the ability to think of atype in its abstract interface leveland use it depending on itsinterface only (without concerningourselves with the implementationdetails; otherwise, there is nothing‘abstract’ about an ADT). SinceOOP is based on the solidfoundation provided byabstraction, it is possible to createcomplex software that hides a lotof implementation details. Becauseof this, object orientation issuitable for programming on alarge scale.Inheritance is the mechanismin which common properties of  various classes (or objects, in caseof object inheritance) areabstracted and provided incommon base classes, therebycreating relationships betweenrelated types. Inheritance isimportant for design since it helpsto organise classes in terms of thenatural relationship between thetypes. In inheritance many of thedetails of the derived classes willonly be known later in the designstage. Also, because of the

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->