In .NET you can mark certain methods as obsolete so that developers are alerted when they attempt to use the deprecated method.
<Obsolete("Do not call this method.")> Private Sub FormerMethod()
The thing is you can only do this within classes you control. What do you do when you want your developers to avoid using certain methods on classes provided natively in .NET or by a vendor?
For example, what if you want your developer to prefer some custom extension method on DataTable rather than Select. I’d hate to have to define a custom version of the DataTable class if only to deprecate Select. That would leave us having to police whether or not the custom table was being used.
I’m aware that there are tools like (FxCop) that help enforce coding standards; however, my question is whether or not this can be handled without some third party tool.
While you may not like the answer, I would think wrapping would be the appropriate choice.
For a third party vendor’s code, wrapping should be mandatory just to produce a level of abstraction for unit testing. And being a wrapper, you can obviously mark methods as
Obsolete.For .NET objects, it’s a little more tricky. Obviously, someone can just include the namespace and go to town; I don’t believe there is a ‘code-only’ solution to this problem like you want, other than perhaps making an integration test that searches over your solution and fails when that particular method you dont like is called.