Trouble understanding Object State, Behavior, and Identity?

前端 未结 5 1186
面向向阳花
面向向阳花 2021-01-30 11:42

I have been instructed by my professor to introduce myself on a page as if I were an object, and that I must address three things:
1) Object State, 2) Behavior, and 3) Ident

5条回答
  •  失恋的感觉
    2021-01-30 12:14

    As a correction to @MrSimpleMind's answer marked as best answer, and elaborating on @JNL's answer:

    Identity is not what makes the object unique in terms of it's state (e.g. name = "Tim" or whatever). Identity however is that an object is unique in terms of it's location in memory.
    If you what to read more about this, you can start by looking at this Wiki page: Identity in OOP

    UPDATE
    It's worth mentioning that it's not always in terms of location in memory. When saving an object to a database, it'll essentially be saved as a row, here an ID column is used.

提交回复
热议问题