How to refactor duplicated code without using helper classes?
From: Sylvain (redhotsly_at_hotmail.com)
Date: 10/30/03
- Next message: Daniel T.: "Re: How to refactor duplicated code without using helper classes?"
- Previous message: Universe: "Re: OO's best feature survey results"
- Next in thread: Daniel T.: "Re: How to refactor duplicated code without using helper classes?"
- Reply: Daniel T.: "Re: How to refactor duplicated code without using helper classes?"
- Reply: Michael Feathers: "Re: How to refactor duplicated code without using helper classes?"
- Reply: Shayne Wissler: "Re: How to refactor duplicated code without using helper classes?"
- Reply: H. S. Lahman: "Re: How to refactor duplicated code without using helper classes?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Oct 2003 13:46:07 -0500
What is the correct way to refactor duplicated code?
Suppose you have Class A and Class B. Some code is duplicated in Class A and
Class B. If there is a base class for these classes or if it is justified to
extract a base class for Class A and Class B then I can move the code there.
However, if Class A and Class B do not have a base class and if it is not
justified to extract a base class, the simple way to resolve the problem is
to move the code in a public static method of a public helper class. But I
don't like helper classes and helper methods; they are too close to function
libraries and too far from OO.
In our project we now have at least 10 helpers classes with dozens of static
methods. I would like to get rid of them but I am not sure how to do so.
Thanks
Syl
- Next message: Daniel T.: "Re: How to refactor duplicated code without using helper classes?"
- Previous message: Universe: "Re: OO's best feature survey results"
- Next in thread: Daniel T.: "Re: How to refactor duplicated code without using helper classes?"
- Reply: Daniel T.: "Re: How to refactor duplicated code without using helper classes?"
- Reply: Michael Feathers: "Re: How to refactor duplicated code without using helper classes?"
- Reply: Shayne Wissler: "Re: How to refactor duplicated code without using helper classes?"
- Reply: H. S. Lahman: "Re: How to refactor duplicated code without using helper classes?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|