Skip to content

Instantly share code, notes, and snippets.

@nicholasjhenry
Created September 19, 2011 13:02
Show Gist options
  • Save nicholasjhenry/1226452 to your computer and use it in GitHub Desktop.
Save nicholasjhenry/1226452 to your computer and use it in GitHub Desktop.
Pat Maddox's example from Streamlined Object Modeling
# http://tech.groups.yahoo.com/group/domaindrivendesign/message/6654
class Target {
public void strike(missile) {
missile.setCoordinates(self.coordinates);
missile.launch();
markDestroyed();
}
}
class PatsHouse extends Target {
public void strike(missile) {
raise new BadIdeaError("Whoa whoa who, I don't want to die");
}
}
as opposed to the Missile class being invasive:
class Missile {
public void strike(target) {
setCoordinates(target.coordinates);
launch();
target.markDestroyed();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment