-
Website
http://andypalmer.com -
Original page
http://andypalmer.com/2008/02/refactoring-design-composed-method/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
Andy Palmer
2 comments · 1 points
-
Rob Myers
1 comment · 1 points
-
tswicegood
1 comment · 1 points
-
-
Popular Threads
public makeBase(Ingredients... ingredients) {
chef.washHandsIn(sink);
bowl.add(ingredients);
chef.mixIngredientsOf(bowl);
cake.addContents(bowl);
}
I'm not claiming this is perfect, but would be more in-line with a first phase refactoring:
1. Washing hands is a behaviour between the chef and sink. The details of which should not be exposed to the cheesecake.
2. The ingredients getting added to a bowl pushes the loop as a single operation into a single method.
3. Might as well move the construction of all the objects but allow them to be injected.
The point of the post was that the first thing we should do is get to a consistent detail level.
I rolled up the "how we wash our hands" into a "what are we doing?" washHands method.
My feeling is that washing hands is nothing to do with the making of the base. The chef should make sure he washes his hands before he starts making the base, but we'll get there eventually :-)