Created
November 16, 2010 22:45
-
-
Save anonymous/702672 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The Single Responsibility of this method is to edit the canvas | |
# given a brush and the point where the user interacted. | |
def editCanvas(canvas, pointer, brush): | |
# The canvas being read only is an exceptional situation | |
# that can be handled by the editCanvas method. | |
# The situation is handled using a guard clause | |
if canvas.isReadOnly: | |
return | |
# This line is a part of the Normal Flow because it is not | |
# contained within a conditional. | |
# The behavior of this line belongs to the Main Flow. | |
# Further, editCanvas has multiple flows it can use to achieve | |
# it's responsibility. This line expresses the Alternate Flow | |
# using polymorphism. | |
brush.apply(canvas, pointer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment