June 16, 2002 - Protecting Your Class Against Extension
June 16, 2002|
Protecting Your Class Against Extension
Tips: June 2002
Yehuda Shiran, Ph.D.
final. Marking your class as
finalis trivial, but does not buy you much. In fact, it can be counter-beneficial. Your classes will not be reused by other team members, and you will not be contributing to the efficiency of the team as you might have done if you shared your classes. Marking selected functions as
finalis a more logical thing to do. In this way, you prevent people from overriding your implementation with the
overridemodifier. You also prevent them from hiding your implementation with the
hidemodifier. So, whether your variable is of the base class or the derived class type, the only definition that rules is yours.
To learn more about JScript .NET, go to Column 110, JScript .NET, Part IV: Inheritance.