17

What is that feature according to you that has made object oriented programming so much successful ?

  1. Message Passing
  2. Inheritance
  3. Polymorphism
  4. Encapsulation

Or some other feature that you may like to introduce.

Also I would like to know that what is the connection between Abstract Data type and Object Oriented programming?

1
  • popular and successful are not synonymous Dec 14, 2012 at 5:38

11 Answers 11

76

I'd suggest that the most important characteristic of object oriented programming is that of complexity management.

The human brain can only hold so many concepts at one time - the oft quoted limit of remembering 7+/-2 independent items comes to mind.

When I'm working on a 600kloc system at work, I can't hold the whole thing in my head at once. If I had to do that, I'd be limited to working on much smaller systems.

Fortunately, I don't have to. The various design patterns and other structures that we've used on that project mean that I don't have to deal with the entire system at once - I can pick up individual pieces and work on them, knowing that they fit into the wider application in well defined ways.

All of the important OO concepts provide ways to manage complexity.

Encapsulation - let me deal with an external API that provides me with various services, without worrying how those services are implemented.

Abstraction - let me concentrate on the essential characteristics and ignore what's not relevant.

Composition - let me reuse components that have already been built in new combinations

Polymorphism - let me ask for a service without worrying about how different objects might provide it in different ways.

Inheritance - let me reuse an interface or an implementation, providing only the pieces that are different from what has gone before.

Single Responsibility Principle - lets keep the purpose for each object clear and concise, so it's easy to reason about

Liskov Substitution Prinicple - let's not lay traps for each other by introducing odd dependencies

Open/Closed Principle - let's allow extension and modification in ways that don't require us to risk breaking existing code

Dependency Injection - let's take composition to the next level and assemble the components together much later.

Interface oriented development - let's take abstraction to the next level and only depend on the abstraction, never on a concrete implementation.

8
  • 6
    +1. I can only vote once, which is a shame this deserves more.
    – Richard
    Nov 2, 2010 at 9:18
  • 1
    There's a corollary to this, it's a shame I can't find the reference right now but I'll try to remember to look it up and edit the comment. So a study of code review practices found that code reviews tended to take longer to find bugs in OO code than procedural code, because the flow jumps around more in OO code. Practices like TDD and pair programming mitigate that, but it's still an interesting (and to me, unexpected) result.
    – user4051
    Nov 2, 2010 at 10:46
  • 5
    This might be the perfect answer - information full, yet short enough so the reader doesn't have to read a novel. Bravo Nov 2, 2010 at 13:45
  • @Graham Lee: I'd be interested in reading that study. Nov 2, 2010 at 17:45
  • 2
    @Frank @Bevan: portal.acm.org/citation.cfm?id=337343
    – user4051
    Nov 2, 2010 at 22:04
13

Graphical user interfaces. In the late eighties, early nineties, when Macs, Amigas, Atari STs, Windows and GEM began to replace character based user interfaces, it became obvious that languages like C are not well-suited to write GUI programs. While traditional data processing is considered as a "input data -> processing -> output data" schema, which could be done in a procedural language just as well, OOs features just came handy to handle the inherent complexity of a GUI.

1
  • 1
    +1 for mentioning GUI applications. Object-orientation was the tool that allowed to implement GUI's, which were otherwise (with procedural code) quite difficult to manage.
    – Giorgio
    Dec 12, 2012 at 14:42
7

The Data Hiding provided by Encapsulation.

6
  • This is an answer? ADTs provide data hiding (which is why they're called "data abstractions") Nov 2, 2010 at 14:29
  • @Frank, He asked for specific features and when I wrote this answer, there was only one other and I was trying not to duplicate.
    – user1842
    Nov 2, 2010 at 18:29
  • Fair enough, but encapsulation's not exactly specific to OO. I should check this myself, but I'm pretty sure we were doing encapsulation long before OO. Nov 2, 2010 at 20:48
  • 1
    @Frank, I agree it's not specific to OO, it's just one of it's main features.
    – user1842
    Nov 2, 2010 at 21:46
  • That's true of most OOPLs, but not of all. CLOS is a notable exception. Nov 2, 2010 at 22:47
7

A feature that hasn't been mentioned yet by any of the other answers: domain modeling. Because people tend to think about doing things with or to objects, and about objects having intrinsic properties, it's very easy to model a problem or workflow using object-oriented software. Essentially, it allows us to use our existing ability to deal with nouns, verbs and adjectives in code.

6

I think inheritance is the most important point of OOP.

[from game development] You can create something like a Drawable class, with rendering methods and attributes, and create a Spaceship and Planet class, which inherits from Drawable. Take all objects from those [and other Sprite child], throw in a drawableObjArray and just call the draw method for every object. You just need to know that it's an Drawable.

3
  • 2
    Really?? Polymorphism is WAY more important and does not require inheritance (from a theoretical standpoint). Sep 11, 2012 at 16:49
  • Does not even require virtual functions just use function pointers.
    – Calmarius
    Dec 12, 2012 at 13:51
  • 1
    Alan Kay's original concept of OO didn't even include inheritance because he didn't like how it was implemented in previous systems. Dec 12, 2012 at 14:11
3

Abstraction

Providing the necessary services hiding the unnecessary things. See my explanation here- What is abstraction?

1
  • Typo: "Absraction" should be "Abstraction"
    – Vetle
    Nov 2, 2010 at 11:00
2

It is somewhat successful because it encourages the use of the human mind's organization of things into objects. People are generally good at seeing relationships of things - things like differences, similarities and behavior. OO encourages developing software to mimic human conceptualization of the world.

Making software development similar to how we view the world makes it easier for our minds to handle the complexity.

1
  • Maybe it's because of more experience with procedural, but after using both methods, I still find procedural more intuitive to do than OOP. I still like the good parts of both styles, though. Dec 12, 2012 at 15:54
1

"ADT vs objects" has been asked a number of times here. The one-line answer is "ADTs and objects are the inverse of each other - what one abstracts neatly the other cannot; each allows flexibility in different ways."

For a longer answer, see William Cook's On Understanding Data Abstraction, Revisited. Briefly, objects allow you to easily use multiple implementations/representations of some datum (something that looks like a list could be an array, or a self-balancing tree, or...) but make it hard to add new operations (because you have to add that new operation to each of your representations), while ADTs make it easy to add new operations on your data type, but make it hard to have multiple implementations.

Edit: I'd said that message passing was what made OO successful. Based on Jonas' comment, that's not right, because most languages that people consider OO don't use message passing. Since it's not right, I culled it from my answer.

3
  • 1
    Message passing can hardly be the answer since none of the successful OOP languages uses it.
    – Jonas
    Nov 2, 2010 at 15:10
  • Your OO isn't necessarily my OO. And most languages that are called OO are not, by Alan Kay's definition. I forget the exact quote, but Kay's said that objects were not what was important about Smalltalk, but message-passing (and that most missed this point). Nov 2, 2010 at 16:18
  • @Jonas I guess, upon rereading the question and my answer, that I'm half-saying "OO isn't successful, since so few languages do it right." But I only say things like that when I'm wearing my flame-proof suit. Nov 2, 2010 at 16:30
0

My top three features. Object Composition - allowing objects to collaborate. Polymorphism - supports dynamic behaviors at runtime. Inheritance - by reusing code and modifying behavior through methods overriding.

ADT - you can have that even in non object-oriented languages like Pascal. A stack or a queue are examples of ADT.

1
  • "ADT - you can have that even in non object-oriented languages like Pascal. A stack or a queue are examples of ADT.": True. But OOP makes it easier to define the interface of an ADT and provide different, interchangeable implementation (interface / abstract class <---> subclasses / concrete classes). As far as I know it is not as easy in Pascal.
    – Giorgio
    Dec 12, 2012 at 15:08
0

in simple words OOP is the key for re-usability and encapsulation that results in the production of large frameworks that makes the life easy for programmers in this era as the can just call the API's and do what day want most often.

as ur question is about the 4 features of OOP so you can say

  1. Inheritance and 4. Encapsulation are the most important features and other two are very much necessary to achieve the first two

so 1. Message Passing and 3. Polymorphism are actually supporting 2. Inheritance and 4. Encapsulation.

  1. Inheritance and 4. Encapsulation are key to success for OOP
1
  • inheritance isn't required, a defining component of, or even a very desireable part of OOP most of the time. encapsulation is a good principle for programming in general. it wasn't invented by OOP and it's not solely used in OOP.
    – sara
    Aug 2, 2016 at 9:41
-1

In my opinion, the last three features are the most important once that impacted the wide spread usage of OOP:

2. Inheritance
3. Polymorphism
4. Encapsulation

Edit: Another point would be IDE and graphical interface development environments like Visual studio and Eclipse. As they embrace OOP languages, thus more and more designs tended towards OOP.

And of course SOLID Principles are the once that make the software products ROCK solid deliverable :)

Not the answer you're looking for? Browse other questions tagged or ask your own question.