a lesson on code poetry

Posted by Jake Good
on Jan 24, 05

so I was reading Eugene's blog post today... and I decided to post the same question here...

An interesting refactoring scenerio...

How do you get rid of the IF statement? (Requires square toimplement multiple “isColor“ methods for each derived robot object...)

--- *EDIT* ---
this is an example of an extreme refactoring exercise... taking pieces of code andensuring there are NO repeated lines and one line method calls... it's supposed toget you thinking about patterns and other ways of refactoring... cause we allknow you should do it 

public class RedFollowingRobot{public void move(){if (nextSquare().isRed())super.move();}}public class Square{public boolean isRed(){...}}

Comments

Leave a response

Comment