T O P I C R E V I E W |
JohnCrenshaw |
Posted - Dec 13 2006 : 11:27:24 AM I recently did a Change Signature on a virtual function changing both the name and some other attributes. I was pleasantly surprised to find that the rename filtered down to all of the derived classes as well, however, the rest of the signature only changed for my base class.
I'd like to make a case for changing the signature across the board, at least where class inheritance and the virtual keyword makes the functions effectively the same.
1. If a virtual function is refactored and remains virtual, it makes sense to change all of the equivalent functions in all derived classes. 2. The reason is that these are functionally the same, and calling the virtual function causes a call to the highest level override defined for the object. 3. If some (but not all) of the the signatures suddenly become different, the function that gets called in any given case has now changed because virtual only works if the signatures are the same. 4. This is bad because the ChangeSignature function should generally leave the code opperating exactly as it did before. (In fact a message is given warning about references not being changed because the user would expect all to work as before.) 5. The references problem for which a message is popped up will generally generate compiler errors/warnings because the function name and/or signature doesn't resolve to a valid symbol anymore, however, this virtual function problem causes neither errors nor warnings in most cases, because all declarations and symbols are just as valid as they were before, even though they are behaviorly different. The absence of warnings means that if a developer is not really on the ball, they could silently introduce major bugs.
|
2 L A T E S T R E P L I E S (Newest First) |
sean |
Posted - Nov 18 2013 : 3:25:40 PM Change Signature was overhauled in build 2007 and now supports changes to a class hierarchy. |
feline |
Posted - Dec 13 2006 : 12:20:55 PM This is on our list of things to consider doing
case=3373 |
|
|