Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 1
    Good answer! One part I don't agree with: the distinction you're drawing about encapsulation isn't valid. Encapsulation always means "forbidding access beyond this interface" -- that's true for OOP and non-OOP settings alike. So this part isn't really something that's unique to OOP. Commented Mar 20, 2017 at 16:05
  • @D.W. I've tried to clarify this, saying not that it's unique to OOP but that it's the difference between encapsulation and abstraction. Thanks for the feedback! Commented Mar 20, 2017 at 17:47
  • 2
    OK. But I still have a different view about what is written here on that subject. You wrote that "here's some ways OOP is more nuanced than what you've said", but encapsulation isn't a way that OOP is more nuanced than what was written in the question. Encapsulation is what it is, in any paradigm. And where you wrote that " What you are describing is not OOP, it's abstraction", I thought the original question was trying to describe encapsulation (not just abstraction). I guess I'll just leave this comment as a different perspective. I do think the answer is very helpful! Commented Mar 20, 2017 at 17:56
  • 1
    Inheritance is a common feature, but several important OO languages lack it. Commented Mar 23, 2017 at 2:34
  • Good answer, but IMO you're overstating the car example. An engine for a given model has a well-defined interface (cam shaft, mounting bracket "receptacles", etc.). You can replace a plain old carburetor with a fuel-injected one, add a turbo-charger, etc. without affecting the transmission. (Although a diesel engine does require a modified fuel tank IIRC.) Conversely, you can replace a manual transmission with an automatic and AFAIK that doesn't affect the engine at all. Commented Mar 23, 2017 at 13:03