I was reading through Oracle‘s introduction to OOP concepts and I came across this description:
Real-world objects share two characteristics: They all have state and behavior. Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail). Software objects are conceptually similar to real-world objects: they too consist of state and related behavior.
My problem with that passage is that when describing state its mixes attributes there too. For instance, the name and color of a dog are its attributes, while it being hungry or thursty are its states.
So in my opinion it‘s more accurate to break the characteristics of objects into three parts: attributes, states and behaviors.
Sure, when translating this into a programming language I can see that the three-fold partition becomes a two-fold one, because both attributes and states will be stored into fields/variables, while behaviors will be store into methods/functions.
But conceptually speaking it makes more sense to have the 3 things separate.
Here‘s another example: consider a lamp. Saying that both the lamp size and whether or not it‘s turned on are states is a stretch in my opinion. The lamp size is an attribute, not a state, while it being turned on or off is a state.
Or did I miss something?