On 05/02/2011 09:36 AM, [email protected] wrote:
Thx, can you be more specific? I'm looking for reasons.

Door>>open, close (delegating to state)
OpenedDoorState>>close
ClosedDoorState>>open

delegation, empty methods, throwing exceptions, that all seems just ugly,
I don't want anybody looking in methods browser
to think that every door can be closed or opened,
because that's not right.

I don't know about "right", but I know its exactly how I would expect the code to read. I would expect the open method to be overridden or check state and behave accordingly. If a door cannot be opened, it is just fine if an open method exists..

Think of it this way: My dog can't speak. She can bark, but doesn't do it on command. If I ask a person "What is your name?" I expect an answer. Although the person may choose not to answer or may not be capable of doing so. That does not mean, that myself, as the sender of the message #speak, would not send the message. Its up to the receiver to behave as the receiver will. Forget about the expectation of the sender and focus on the behavior of the receiver. Smalltalk is an exploratory environment. Also don't be so focused on classes, but on objects.

~Jon

Reply via email to