13.07.2015 Views

Smalltalk Best Practice Patterns Volume 1: Coding - Free

Smalltalk Best Practice Patterns Volume 1: Coding - Free

Smalltalk Best Practice Patterns Volume 1: Coding - Free

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BehaviorObjects model the world through behavior and state. Behavior is the dynamic, active,computational part of the model. State is what is left after behavior is done, how the model isrepresented before, after, and during a computation.Of the two, behavior is the more important to get right. The primacy of behavior is one of the oddtruths of objects, odd because it flies in the face of so much accumulated experience. Back in thebad old days you wanted to get the representation right as quickly as possible, because everychange to the representation bred changes in many different computations.Objects (done right) change all that. No longer is your system a slave of its representation. Becauseobjects can hide their representation behind a wall of messages, you are free to changerepresentation and only affect one object.Behavior in systems of objects is specified in two ways, with messages and methods. I saw a greatcomment at OOPSLA (the Object Oriented Programming Languages, Systems and Applicationsconference). It said, “This seems an awful fuss for a fancy procedure call.” Well, separatingcomputation into messages and methods and binding the message to the method at runtime basedon the class of the receiver may seem like a small change from an ordinary procedure call, but it isa small change that makes a big difference.This section tells you how to specify behavior so that your intent is clearly communicated to yourreader. Many constraints affect your choices when specifying behavior. The more centralized theflow of control, the easier it is to follow in the sense that you don’t have to go bouncing around allover the place to understand how work is accomplished. However, centralizing control killsflexibility. You want to have lots of objects involved, so you have many opportunities to replaceobjects to change the system, and so you can completely factor code.<strong>Coding</strong> <strong>Patterns</strong> page 22 of 147 9/30/2006

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!