views:

34

answers:

3

I often get scary whenever I need to rename a method since it's very likely to break other working codes. What is the best guidance to follow when doing this?

+2  A: 

I think the best is to create a new method and mark the old one as "deprecated" (you can do that in .net, I don't know what platform you are developping for).

Use the attribute Obsolete and every call to the method will get a warning in Visual Studio:

<Obsolete()> _
Private Sub FillGridView(ByVal searchResult As List(Of Comptabilite.OrderLine))
GôTô
I'm working with Visual Studio.
Nam Gi VU
+2  A: 

Distibguish between public APIs and your internal implementaiton. If you structure your code well in the first place then code that depends on your code will use a small, well-defined API often presented as explicit Interfaces.

Whereever possible make your changes to public APIs back-compatible. Often you can deprecate existing methods and offer the new ones. Then later remove the old ones.

djna
+2  A: 

Deprecating the old version and working with the new version is the way to go.

On the other hand: if you can get away with a simple search-and-replace on the whole codebase, that seems fine to me as well. Some people may grumble when they find their code changed upon their next update, but it's fast and spares you the hassle of having to shlep around obolete methods for who knows how long.

Christian Severin