1

I have a framework class that is used in a number of our applications. This class has 6 constructor overloads at present. I need to add an extra parameter to each overload to handle an extra scenario. To do this I figure I have three options:

1) Update all the overloads with the extra parameter. This has the disadvantage of breaking existing application code (if they get updated to use the new version)

2) Create an extra overload for each current overload including the new parameter. This has the disadvantage of cluttering my code up with 6 extra methods.

3) Adding an optional parameter to each method to accomodate the extra parameter. This has the disadvantage that many of my colleagues dislike optional parameters.

What is best practice in this situation?

Many thanks,

Jamie

majjam
  • 1,286
  • 2
  • 15
  • 32
  • Have you considered refactoring to more of a builder pattern? That lends itself to this sort of thing very easily. – Jon Skeet Jul 26 '13 at 08:30
  • Thanks Jon, following your suggestion I've found this post: http://stackoverflow.com/questions/328496/when-would-you-use-the-builder-pattern it looks like the builder will be a good fit. – majjam Jul 26 '13 at 09:25

0 Answers0