OOP: When is it an object?

前端 未结 20 1355
悲哀的现实
悲哀的现实 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:45

    Everything is an object. From quarks over electrons, atoms to elements, dust, men, cars, the world and the universe.

    Even thoughts, ideas or feelings are objects.

    (So far for the obvious answer)

    Coming to "deciding what deservers to be an object"; I alawys to it as simple as does it have to behave in any way and will it be used more than once.

    As soon as you use anything more than once, it's worth being a function or even an object.

    Furthermore; will it be reused by other things? (Objects, Projects, Programs, etc.) These are the thoughts I have when I decide what should and what sould not be an object.

    But, as I said above, the question is trivial, as everything is an object by itself.

提交回复
热议问题