Is OO design's strength in semantics or encapsulation?

后端 未结 11 1377
余生分开走
余生分开走 2021-01-30 23:28

Object-oriented design (OOD) combines data and its methods. This, as far as I can see, achieves two great things: it provides encapsulation (so I don\'t care what data there is,

11条回答
  •  深忆病人
    2021-01-31 00:05

    IMHO, OO simply means objects interacting with other objects. Encapsulation simply means abstracting a concept. So, you create a Socket and .Connect() to something. How it connects, you don't really care (which is basically my definition of encapsulation).

    And, pure functional programming can use object to communicate.. but those objects need to be immutable. So, again IMHO, FP can easily use OO concept; Imperative language such as C can still use the concept of OO.. for instance, a file for each "Class" with a private section that shouldn't be used.

提交回复
热议问题