473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What is your weightage of the 3 characteristics of Object-Oriented Programming....

Hi All,

What is your weightage of the 3 characteristics of Object-Oriented
Programming
i.e. Inheritance, Encapsulation and Polymorphism. for a total of 100%

Please quote your values and let's discuss how the people thinking about OOP

:-)
Regards,
....@shok
------------------------------------------------------------------------
"It is beautiful for an engineer to shape and design the same way
that an artist shapes and designs. But whether the whole process
makes any sense, whether men become happier - that I can no
longer decide." - Rudolph Diesel

Nov 17 '05 #1
19 1784
"G.Ashok" <gw******@hotmail.com> a écrit dans le message de news:
Oz**************@TK2MSFTNGP09.phx.gbl...
What is your weightage of the 3 characteristics of Object-Oriented
Programming
i.e. Inheritance, Encapsulation and Polymorphism. for a total of 100%


What about Aggregation, Composition and Delegation ?

Joanna

--
Joanna Carter
Consultant Software Engineer
Nov 17 '05 #2
I don't know about "relative weightage"... I don't know if that even
means anything.

However, I claim that Encapsulation is usually the principle that has
the most ready application... it's easiest to see immediate and direct
advantages to encapsulation, so it's easy for old procedural
programming hacks like me to see what it's for.

Next comes Inheritance, which doesn't make a whole lot of sense unless
you first understand encapsulation. After writing a lot of stand-alone,
encapsulated classes, it starts to make sense why you'd want
inheritance.

Finally, Polymorphism is the most abstract of the three. Once you have
encapsulation and inheritance, you start to see scenarios in which
polymorphism would be useful.

This says nothing about their relative importance to success of
software projects, or their frequency of use in the industry. It's just
the order in which I recommend that programmers new to O-O tackle them,
becaues the benefits of each tend to be clearer when approached this
way.

Nov 17 '05 #3

Joanna,

Delegation, Containment, are all I think design patterns and not key
characteristics of OOP. These are all used in VB6 like langauages. Rest of
the things are conceptual terms of OOA and OOD etc. of cource all are
applied to OO.

Regards,
....Ashok
"Joanna Carter (TeamB)" <jo*****@nospamforme.com> wrote in message
news:e4*************@TK2MSFTNGP15.phx.gbl...
| "G.Ashok" <gw******@hotmail.com> a écrit dans le message de news:
| Oz**************@TK2MSFTNGP09.phx.gbl...
|
| > What is your weightage of the 3 characteristics of Object-Oriented
| > Programming
| > i.e. Inheritance, Encapsulation and Polymorphism. for a total of 100%
|
| What about Aggregation, Composition and Delegation ?
|
| Joanna
|
| --
| Joanna Carter
| Consultant Software Engineer
|
|
Nov 17 '05 #4
"G.Ashok" <gw******@hotmail.com> schrieb:
Delegation, Containment, are all I think design patterns and not key
characteristics of OOP. These are all used in VB6 like langauages. Rest of
the things are conceptual terms of OOA and OOD etc. of cource all are
applied to OO.


Encapsulation and polymorphism are no typical OO features too, they can be
implemented in simple procedural programming languages up to a certain
extent.

PIE (polymorphism, inheritance, and encapsulation) is a minimal subset of
language features which are required for a programming language language to
be called an object-oriented programming language. Each of the features
alone doesn't necessarily have to do with object-orientation.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 17 '05 #5
JAL
#1 The use of objects.

Nov 17 '05 #6
#1 the use of reusable and redesignable classes. From which as much objects
as needed can be instanced.

For me is the rest academically, nice when you learn it, however like
driving not important anymore when you drive a car. most things go
automatic.

Cor
Nov 17 '05 #7
#2 Inheritance. The use of objects without inheritance is object based
programming.

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #8
"Jeff Louie" <je********@yahoo.com> wrote in message
news:ur**************@TK2MSFTNGP12.phx.gbl...
#2 Inheritance. The use of objects without inheritance is object based
programming.


Actually, I'd go with Polymorphism, without which, Inheritance is
pointless.

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
Nov 17 '05 #9
OK, he posted this message, over 3PM on a Friday.... So, how many people
here are thinking "take-home exam" ?

Now, the first question that must be asked is, "What is the question?
Which is more important to OOP? or which is more important to good program
design?"

To the latter, Encapsulation (and data hiding) is, by far, the most
important design characteristic. Having your data properly factored in
objects is the primary key to a well-design program. If I had to put a
number of it, it would be about 65-75%. Polymorphic behavior come next,
which I'd put at about 10-20%. These leaves somewhere between 5-25% for
everything else, of which I'd put Inheritance rather low, maybe 0-5%.
Inheritance is an important technique in OOP, but it's just one technique to
implement polymorphism (one of many -- for example, generic programming
accomplishes many of the tasks of OOP without inheritance). We've learned
that deeply rooted class library are often more of a hinderance than a help,
and most modern class libraries tend to be very shallow.

--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com

"G.Ashok" <gw******@hotmail.com> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Hi All,

What is your weightage of the 3 characteristics of Object-Oriented
Programming
i.e. Inheritance, Encapsulation and Polymorphism. for a total of 100%

Please quote your values and let's discuss how the people thinking about OOP
:-)
Regards,
...@shok
------------------------------------------------------------------------
"It is beautiful for an engineer to shape and design the same way
that an artist shapes and designs. But whether the whole process
makes any sense, whether men become happier - that I can no
longer decide." - Rudolph Diesel

Nov 17 '05 #10
On Mon, 16 May 2005 11:50:01 -0400, "James Curran"
<ja*********@mvps.org> wrote:
"Jeff Louie" <je********@yahoo.com> wrote in message
news:ur**************@TK2MSFTNGP12.phx.gbl...
#2 Inheritance. The use of objects without inheritance is object based
programming.


Actually, I'd go with Polymorphism, without which, Inheritance is
pointless.

They certainly go hand in hand, but I would say inheritance is the
key. Without inheritance, polymorphism is questionable at best - if
it even makes any sense. But without polymorphism, inheritance is
still a huge design advantage.

I don't know if you include overriding methods under the heading of
"polymorphism" - I don't. And just with the ability to override
methods in derived classes so that you can write code that speaks in
terms of base classes (say, "animal" or "mammal") but actually
processes based on the derived classes (say, "cat" or "dog") is the
KEY to OO. It's where the power is. You can write a program that
says "feed the animal", and the dog or cat or cow or bird or marmoset
will be fed correctly, even though your bit of code that controls the
daily routines of the animals doesn't distinguish what kind of animals
are being fed. THAT is the power of OO design and programming.
Nov 17 '05 #11
"goody8" <go****@goody8.com> wrote in message
news:5r********************************@4ax.com...
I don't know if you include overriding methods under the heading of
"polymorphism" - I don't.
I do, because....(see below)
that you can write code that speaks in
terms of base classes (say, "animal" or "mammal") but actually
processes based on the derived classes (say, "cat" or "dog") is the
KEY to OO. It's where the power is.


And that is the very definition of "polymorphism"

Overriding methods is merely an implementation technique to achieve
polymorphism. And, in general, in OO, Implemenation Is Irrelevant. (my OO
mantra)

In fact, overriding virtual functions gets away from true OO-ness. In
strict OO,
windows w;
file f;
w.open(0,0, 100, 200);
f.open("output.txt");

is an example of polymorphism, even though classes window & file would share
no parent other than Object (since in strict OO, we are sending the same
message -- "open" -- to both objects)

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com

Nov 17 '05 #12
On Mon, 16 May 2005 15:16:44 -0400, "James Curran"
<ja*********@mvps.org> wrote:
"goody8" <go****@goody8.com> wrote in message
news:5r********************************@4ax.com.. .
I don't know if you include overriding methods under the heading of
"polymorphism" - I don't.


I do, because....(see below)
that you can write code that speaks in
terms of base classes (say, "animal" or "mammal") but actually
processes based on the derived classes (say, "cat" or "dog") is the
KEY to OO. It's where the power is.


And that is the very definition of "polymorphism"

Overriding methods is merely an implementation technique to achieve
polymorphism. And, in general, in OO, Implemenation Is Irrelevant. (my OO
mantra)

In fact, overriding virtual functions gets away from true OO-ness. In
strict OO,
windows w;
file f;
w.open(0,0, 100, 200);
f.open("output.txt");

is an example of polymorphism, even though classes window & file would share
no parent other than Object (since in strict OO, we are sending the same
message -- "open" -- to both objects)

But that's not polymorphism because w and f are not related. It's
just to unrelated things that happen to have member functions with the
same names.

I would, however, revise my earlier statement. My brain farted -
sorry. Overriding a method IS polymorphism. I guess I was thinking
more of methods with the same names that have different parameters.
But overriding methods is still polymorphic behavior.

But anyway, the inheritance hierarchy and the polymorphism go
hand-in-hand, and that is where the power of OO comes from. Sure,
it's also valuable to encapsulate within objects, but you can do that
sort of organization even with procedural languages, so I guess I
don't see that as a particularly great *advantage* of OO - it's not
unique to OO.
Nov 17 '05 #13
goody8 wrote:
But that's not polymorphism because w and f are not related. It's
just to unrelated things that happen to have member functions with the
same names.
No, that *is* Polymorphism. That was exactly the point I was trying to
make. You are confusing an implementation detail with an OO design concept.
The essence of Polymorphism is that two different objects respond
differently to the same message.

I guess I was thinking
more of methods with the same names that have different parameters.
And that too is polymorphism. Different responses to the same message.
But anyway, the inheritance hierarchy and the polymorphism go
hand-in-hand, and that is where the power of OO comes from. Sure,
it's also valuable to encapsulate within objects, but you can do that
sort of organization even with procedural languages, so I guess I
don't see that as a particularly great *advantage* of OO - it's not
unique to OO.


Which is why I posed the question I did at the very start of this thread:
"What is the question?
Which is more important to OOP? or which is more important to good program
design?" But who cares if a certain principal is part of strict OO or not.
What's really important is if it is a principal of good design.

--
Truth,
James Curran [erstwhile-MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
Nov 17 '05 #14
James... you're a Smalltalk programmer aren't you? :) Your definition
of "polymorphism" is very implementation-dependent: it's very
Smalltalk.

I side with goody8 on this one: it's "polymorphism" only when you can
treat two objects interchangeably for the purposes of some operation,
because they implement that same operation (with possibly different
implementations, but it's the same operation).

In C#, the fact that two methods have the same name is irrelevant. They
must have the same name and the same signature in order to participate
in polymorphic behaviour. In other languages it may be different. C#
has no concept of "message".

Nov 17 '05 #15
> James... you're a Smalltalk programmer aren't you? :) Your definition
of "polymorphism" is very implementation-dependent: it's very
Smalltalk.
Well, yes, my first OO language was SmallTalk, although I was taught ST
in the context of learning OO. Which brings us to your
"implementation-dependent" line --- Actually, it just the reverse -- It's
*your* definition that limited by a particular implementation. I do not
speak in any particular implementation but in the concepts of OO as they
were originally defined (by the person to defined OO and at the same time
defined SmallTalk to implement them).
I side with goody8 on this one: it's "polymorphism" only when you can
treat two objects interchangeably for the purposes of some operation,
because they implement that same operation (with possibly different
implementations, but it's the same operation).
And why would you say that "opening a window" and "opening a file" are
not the "same operation with [a] different implementation" ? So, the
implementation is radically different. Nevertheless, the message "opens"
the object for use.
In C#, the fact that two methods blah blah blah blah blah blah blah blah


First of all, this is precisely why C++ & C# are consider "imperfect" OO
languages. Good enough to get work done, but they don't reach the theoretic
standard of Perfect OO.

More to the point, who said we are talking about "OO as implemented by
C#" ?? Reread the OP. It just talks about "Object Oriented Programming".

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com

"Bruce Wood" <br*******@canada.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...

In C#, the fact that two methods have the same name is irrelevant. They
must have the same name and the same signature in order to participate
in polymorphic behaviour. In other languages it may be different. C#
has no concept of "message".

Nov 17 '05 #16
> More to the point, who said we are talking about "OO as implemented
by C#" ?? Reread the OP. It just talks about "Object Oriented
Programming".

True... but then who said we are talking about "OO as implemented by
Smalltalk?"

In Smalltalk, the name of a message defines the message. "open" as
handled by a File is the same message as "open" as handled by a Window,
so having two objects handle messages with the same name results in
polymorphism _in Smalltalk_.

In C#, C++, and Java, having two classes implement methods with the
same _short_ name _and even the same signature_ does not necessarily
mean that they are processing what you would call the "same message"
and therefore exhibiting polymorphic behaviour. C#, C++, and Java
require that the _full_ method name (including the name of the
interface or base class in which it is defined, and in C# including the
name of the assembly in which that interface or base class was defined)
_and_ the method signature be identical in order that the two objects
exhibit polymorphic behaviour.

What's at issue here is "what is the name of the method" (or, if you
prefer, "the name of the message"). In Smalltalk, the name of the
message is "open". In C#, the name of the method is
AssemblyName.Namespace.Interface.Open(string, string) or some such
thing, not simply "Open". Therefore, if one class implements
AssemblyName.Namepace.Interface.Open(string, string), and another
implements AssemblyName.Namespace.BaseClass.Open(string, string), the
two methods _do not_ have the same name, and therefore there is no
polymorphism.

This is even clearer in C++, which does name mangling: the run-time
message names (or method names) can be quite different, even if what
appears written in the code is simply "Open". Different run-time
message names means no polymorphism.

Different languages implement O-O in different ways. Just because a
particular syntax in one language results in polymorphic behaviour (or
doesn't) doesn't mean that it will (or won't) in another language. It
so happens that C#, C++, and Java have a (reasonably) common
interpretation of what results in polymorphic behaviour. Smalltalk is
different. Each approach has its upside and downside; I don't see any
reason why either is "inferior" in any general sense.

Nov 17 '05 #17
Upon thinking about this further, what's at issue here is not so much
"what is the name of the method (or message)", but syntax versus
semantics.

I see polymorphism (independent of programming language) from a
different angle: "Polymorphism" is happening when you can invoke the
same behaviour in objects of diverse classes. I don't even care about
the name of the method, property, or message at work, so long as it
conceptually implements the "same operation". That is to say, I can
even imagine a language in which the methods / properties / messages
have different names, but are somehow identified as implementing the
"same operation" in some larger sense. Polymorphism, then, isn't about
syntax at all. It isn't about what method name is typed in the code.
Polymorphism is a behaviour, not a notation. It's about being able to
treat disparate objects interchangeably for the purposes of certain
operations.

However a particular language allows you to treat disparate objects
interchangeably for some operations... that is how it implements
polymorphism. Even if "this" language allows a syntax that would
produce polymorphic behaviour in "that" language, but that syntax
doesn't allow you to treat disparate objects as interchangeable in
_this_ language, then in _this_ language the syntax does not indicate
polymorphism. Again, it's about semantics, not syntax. In Smalltalk,
the _syntax_ of naming two messages the same results in polymorphic
semantics. In C#, even overloading method names doesn't introduce the
possibility of polymorphic behaviour; only inheritance and interface
implementations introduce that possibility _in C#_. In some other
language it may be different yet again.

Therefore, in Smalltalk, sending the message "open" to a Window and
sending the message "open" to a File is, in fact, an example of
polymorphism, because that's how Smalltalk implements polymorphism: by
naming two messages the same you are _ipso facto_ indicating that you
want polymorphic behaviour.

In C#, C++, and Java, two methods with the same name (even the same
full name, as outlined in my previous post) are _not necessarily_ the
same operation, and therefore do not necessarily indicate that you want
polymorphic behaviour.

Nov 17 '05 #18
Bruce Wood <br*******@canada.com> wrote:
Upon thinking about this further, what's at issue here is not so much
"what is the name of the method (or message)", but syntax versus
semantics.

I see polymorphism (independent of programming language) from a
different angle: "Polymorphism" is happening when you can invoke the
same behaviour in objects of diverse classes.
I agree, but think that although the classes can be diverse, they
should indicate the relationship between them in some way (i.e. say
that the operation *is* the same one, not just one with the same name).
I don't even care about the name of the method, property, or message
at work, so long as it conceptually implements the "same operation".
That is to say, I can even imagine a language in which the methods /
properties / messages have different names, but are somehow
identified as implementing the "same operation" in some larger sense.


Sure - and indeed in VB.NET you can implement an interface's method
with a different implementation method name.

I believe this is very different to James's view though - I wouldn't
say that opening a file and opening a window *are* the same operation,
really. I wouldn't expect them to be indicated to be the same operation
in any language where that indication is explicit.

A better example would be "Join" - look at String.Join and Thread.Join.
They are radically different operations with the same name. I certainly
wouldn't view those as polymorphically related, even though Smalltalk
would. No doubt Smalltalkers would argue that they're definitely
related *because* they share the same name, but until natural language
becomes completely unambiguous, I think it's a bad way of implying
relationship.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #19
> A better example would be "Join" - look at String.Join and
Thread.Join.
They are radically different operations with the same name. I certainly wouldn't view those as polymorphically related, even though Smalltalk would. No doubt Smalltalkers would argue that they're definitely
related *because* they share the same name, but until natural language becomes completely unambiguous, I think it's a bad way of implying
relationship.


String.Join and Thread.Join are a great example. (I was trying to come
up with an example like that... thanks, Jon.)

This is starting to look more and more like the "strongly typed
language" versus the "weakly typed language" debate, isn't it? It's
like the discussion between VB6 programmers, who are used to having an
"anything" type that they can just stuff values into, and C++
programmers who are used to the rigour of having to declare everything
and be concerned with casting and type conversions. The VB6 guys I knew
used to laugh at C++ and all of the picky housekeeping details you had
to look after in that language; the C++ used to sniff at the VB6 guys
and all of the bugs that cropped up because you inexplicably ended up
with a bitmap in a variable you thought contained an integer.

It strikes me that Smalltalk implements what I would call "weakly typed
polymorphism": same name = same operation. The upside is that you don't
have to worry about picky housekeeping details: the language sorts it
out at runtime. The downside is that you get polymorphism even when it
isn't appropriate and you don't want it, allowing you to do stupid
things like confuse concatenating two strings (String.Join) with
waiting for a thread to complete (Thread.Join). C++, Java, and C# all
implement what I would call "strongly typed polymorphism", where the
programmer has to explicitly indicate that he wants polymorphism, and
keep careful track of what overrides what. The upside is that you get
polymorphism only where you explicitly indicate it; the downside is
that there is lots of picky housekeeping to do.

The fact that both strongly-typed and weakly-typed languages continue
to flourish tells me that each has something to offer. I would say the
same with the two approaches to polymorphism.

I should add that given the mandate of the .NET Framework and C#,
weakly-typed polymorphism seems to me to be a total non-starter in this
environment. The C# / .NET designers took great pains to ensure that
you couldn't possibly introduce rogue code that would override and
redefine things in order to create security holes, or in order to take
over threads for nefarious purposes. I'm not sure how you would mix
that kind of locked-down rigour with a language that sorts out its
polymorphism issues at run-time. They seem like oil and water to me,
although that may just be lack of imagination on my part. :)

Nov 17 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
18
by: Matt | last post by:
Hi, I have a probelm here: If I declare: char *p="Hello";
100
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
13
by: ranjeet.gupta | last post by:
Dear All What does exactly below code means struct File { void* data; }; typedef struct File File; typedef File* fl;
64
by: ng5000 | last post by:
Hi, What's the point of a signed char? As I see it a char represents a character (not an integer, use an int type e.g. short int if you want an 8 bit number, or one of the new types, uint8 I...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
50
by: lovecreatesbea... | last post by:
Could you extract examples of the characteristics of C itself to demonstrate what the advantages of C are? What are its pleasant, expressive and versatile characteristics? And what are its...
10
by: timor.super | last post by:
Hi all, Imagine I've an array of int : int anArray = new int; I want to extract all the integer that are superior to 500 I can do :
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.