문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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.

The Data Hiding provided by Encapsulation.

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.

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.

Abstraction

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

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.

"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.

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.

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

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 :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top