What question(s) does an object's behavior answer?

Posted by Corwin on Stack Overflow See other posts from Stack Overflow or by Corwin
Published on 2010-03-09T09:02:29Z Indexed on 2010/03/09 9:06 UTC
Read the original article Hit count: 213

Filed under:
|

Reading a book I have found the following statement:

(Object) Behaviors answer either of two questions: What does this object do (for me)? or What can I do to this object? In the case of an orange, it doesn’t do a whole lot, but we can do things to it. One behavior is that it can be eaten.

In my understanding of object behaviour the statement above is correct regarding the first question and is incorrect in case of the second. However, I often see classes with methods like Orange::eat(), and this makes me uncertain about my design skills. So I would like to ask is it a design mistake to give oranges a behaviour eat? (oranges and eat are used just for example)

© Stack Overflow or respective owner

Related posts about ood

Related posts about object-oriented-design