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?

Frank Shearar
  • 16,643
  • 7
  • 48
  • 84
Tony
  • 603
  • 1
  • 5
  • 10

11 Answers11

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.

Bevan
  • 3,170
  • 20
  • 22
  • 6
    +1. I can only vote once, which is a shame this deserves more. – Richard Nov 02 '10 at 09: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. –  Nov 02 '10 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 – Tim Claason Nov 02 '10 at 13:45
  • @Graham Lee: I'd be interested in reading that study. – Frank Shearar Nov 02 '10 at 17:45
  • 2
    @Frank @Bevan: http://portal.acm.org/citation.cfm?id=337343 –  Nov 02 '10 at 22:04
  • many if not most of these points are not specific to OOP. they are just all around "good practices" for managing complexity in programming. – sara Jul 28 '16 at 14:17
  • @kai They weren't universally agreed as good practices prior to the OO programming boom of the late 1980s - some of them hadn't even been formulated back then. – Bevan Aug 01 '16 at 22:27
  • @Bevan maybe, I won't argue that here, but that doesn't mean you need to use OOP to have the advantages. also, the basic principles which most of these stem from (composing simple parts, hiding implementation details and so on) are old as time itself and are just as, if not more, prevalent in FP which is a way older paradigm than OOP. at the end of the day, OOP mainly served to make a bunch of patterns and principles mainstream, it didn't invent the fundamental ideas. – sara Aug 02 '16 at 09:38
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.

user281377
  • 28,352
  • 5
  • 75
  • 130
  • 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 '12 at 14:42
7

The Data Hiding provided by Encapsulation.

  • This is an answer? ADTs provide data hiding (which is why they're called "data abstractions") – Frank Shearar Nov 02 '10 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. –  Nov 02 '10 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. – Frank Shearar Nov 02 '10 at 20:48
  • 1
    @Frank, I agree it's not specific to OO, it's just one of it's main features. –  Nov 02 '10 at 21:46
  • That's true of _most_ OOPLs, but not of all. CLOS is a notable exception. – Frank Shearar Nov 02 '10 at 22:47
  • +1, described everything in a sentence. That either deserves an upvote for being to the point or a downvote for being too brief. I chose the former. :D – ApprenticeHacker Jan 31 '12 at 10:33
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.

JulioC
  • 533
  • 2
  • 10
3

Abstraction

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

Gulshan
  • 9,402
  • 10
  • 58
  • 89
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.

Tim
  • 946
  • 7
  • 9
  • 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. – Juha Untinen Dec 12 '12 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.

Frank Shearar
  • 16,643
  • 7
  • 48
  • 84
  • 1
    Message passing can hardly be the answer since none of the successful OOP languages uses it. – Jonas Nov 02 '10 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). – Frank Shearar Nov 02 '10 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. – Frank Shearar Nov 02 '10 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.

  • "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 '12 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
  • 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 02 '16 at 09: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 :)

Yusubov
  • 21,328
  • 6
  • 45
  • 71