Tell Don't Ask, unit tests and mutable state

If you follow the "Tell, Don't Ask" style, objects have very little visible state to assert about.


When writing a program, I care only about what that program does, not the internal state that the program uses to control what it does. The only visible behaviour that a program has is its interactions with external entities


Mutable state makes a program harder to understand and maintain


"Doing encapsulation right is a commitment not just to abstraction of state, but to eliminate state oriented metaphors from programming." — Alan Kay

Read the full post:

Print | posted @ mercoledì 18 agosto 2010 17:34

Comments on this entry:

Gravatar # re: Tell Don't Ask, unit tests and mutable state
by Antonio Ganci at 19/08/2010 11:36

Nel post che hai segnalato è linkato anche il pdf di The Early History of Smalltalk se non l'hai ancora fatto è una lettura molto interessante sull'object oriented (anche se un po' difficile). Perchè descrive da cosa è nata l'idea dell'oo e di come poi purtroppo si è sviluppata in una direzione diversa.
Comments have been closed on this topic.