[squeak-dev] PluggableButtonMorph>>askBeforeChanging

Igor Stasenko siguctua at gmail.com
Sat Jan 23 02:43:16 UTC 2010


As to me this is a good example of placing a decisive role into wrong place,
bloating the morph's protocol.

The 'askBeforeChanging' is used in #performAction
which asks the model , if it wants to change:
	askBeforeChanging ifTrue: [model okToChange ifFalse: [^ self]].

But why doing that, isn't model unable to send #okToChange in its own
action handling method?
i.e. if button does:
   model perform: actionSelector

where actionSelector == #foo,

what prevents a model to implement this method as:

foo
  self okToChange ifFalse: [ ^ self].
  self doSomething.

?

Or, even if model wants to do something without asking in one case,
but with asking in another,
what prevents it to implement:

#doSomething
and
#doSomethingIfOkToDoIt

and choose appropriate selector as action to a button(s)?

Or, if we look at it from different angle.
A button widget main role is to trigger some action.
The action could be anything: from very simple one up to complex, composite one.
And 'ask-before-change-then-do' is an example of composite action.
So, let button just trigger that composite action.
Why putting an action handling logic to the place where action having
completely abstract meaning?

-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list