4 ms·
OOP is defined primarily by its ability to abstract and encapsulate data (and state) in objects. See William Cook's paper on "On Understanding Data Abstraction,
by seanmcdirmid 14y ago
OOP is defined primarily by its ability to abstract and encapsulate data (and state) in objects. See William Cook's paper on "On Understanding Data Abstraction, Revisited." Of course, there are other ways to encapsulate state; e.g., as monads; OOP doesn't promote encapsulation so much as it promotes encapsulation using objects. The second defining aspect of OOP is messaging (goes along with encapsulation); Alan Kay has more to say about that (just check out Message Passign on wiki). The third is probably dynamic dispatch and polymorphism; not all OOP languages have that.
I've dealt with plenty of weird non-procedural OO languages (including my own) with no recognizable procedure construct, but this is a much more controversial position as there are no mainstream non-procedural OOP languages out there (Erlang?). However, procedural programming is mostly orthogonal to OOP, which is what I think the blog post is trying to get across?
- danieldk 14y agoOOP is defined primarily by its ability to abstract and encapsulate data (and state) in objects. I cannot help but thinking this is a tautology: 'Programming with objects is defined by putting data in an objects.' What is an object? How does it defer from other data structures where its members are hidden to the outside world? I am not arguing that OOP does not exist, just that one aspect that has always been touted as one of its greatest advantages, also exists in most non-OO languages. The second defining aspect of OOP is messaging (goes along with encapsulation); Alan Kay has more to say about that (just check out Message Passign on wiki). The third is probably dynamic dispatch and polymorphism; not all OOP languages have that. Is message passing without dynamic dispatch and polymorphism really message passing? (In contrast to a function call that has a structure as an implicit argument?) there are other ways to encapsulate state; e.g., as monads A data type is a monad if a function is provided that defines how computations of that data type can be combined[1], and that function obeys the monad laws. A monad can be used to combine effectful computations (IO, ST) or threading state through function calls (State). But e.g. the list, Maybe, or Either monads have little to do with state. [1] Excluding 'return' for brevity ;).
- seanmcdirmid 14y agoMonads can be used to encapsulate state, they are used for other things. You can use objects to encapsulate state, or you can use another style of data abstraction, whatever floats your boat. OOP has no unique capabilities, you just get to design your programs around objects, which is good enough for me. Its all about design.
- deleted 14y ago[deleted]