Thursday, January 17, 2013

Preserve Whole Object


Sometimes you will obtain some data from an object to be parameters of a method. The problem is that if the method needs the new data from this object, you would have to look up and modify all of invocations to this method. So if you passed the whole object as the parameter to this method, you will avoid this problem.
And this refactoring (Preserve Whole Object) can also improve the readability.
And when you apply "Preserve Whole Object", you find the invoked method need a lot of attributes of this object. You need to consider use "Move Method" to do the code refactoring. So "Preserve Whole Object" can help you to know whether your code need to do "Move Method" refactoring.

No comments:

Post a Comment