Software Design/Extract Wrapper Object

Extract Wrapper Object is a refactoring primarily aiming at removing logic duplication in the code as per DRY principle. Extract Wrapper Object is related to Extract Class and Introduce Parameter Object refactorings.

Examples
If there is some code working with coordinates  and   and repeatedly performing operations such as negation: The coordinates could be grouped into a  object on which   function can be defined:

For another example, there may be a class with several operations and in some cases some aspect should be attached to calling those operations, such as logging or notifying some listener:

Then a decorator class such as  can be extracted to gather the repetition of the aspect's logic in one place:

Related refactorings and practices

 * Extract Class
 * Don't repeat logic in several places
 * Extract parts of a class into smaller classes