Wednesday, February 22, 2006

Marking a method as obsolete

I am currently working on an enterprise system that already has several consumers. There are several methods that have been replaced by newer methods and I want the clients to stop consuming the old ones. Unfortunately if I just tell them to use the new ones they wont, and when I release a new version and it breaks they will complain. I found a neat way to deprecate a method

1 _

2 Public Function oldWay() As Boolean

3

4 End Function



now whenever a consumer compiles they will get a compiler warning stating that the method has been replaced by method newWay()

You can also make the compile give a warning instead of an error by using one of the overloads

1 _


By setting the last parameter to true the compiler will show an error instead of a warning.

(the first example I posted might actually show an error instead of a warning. I will post more once I experiment with it)

0 Comments:

Post a Comment

<< Home