OOP: When is it an object?

前端 未结 20 1609
悲哀的现实
悲哀的现实 2021-01-30 23:01

I\'m trying to understand object orientation. I understand it a little bit of course, but sometimes I\'m not 100% clear. How do you decide what should be turned into an object (

20条回答
  •  死守一世寂寞
    2021-01-30 23:38

    This depends a bit on the usage. To go with your example, if the doorknob is an important part and could (potentially) be used on another door (or a different knob be used for 'this' one) then it should probably be an object.

    If on the other hand it is only there to allow you to open and close the door, it should simply be a part of the door object.

提交回复
热议问题