Virtual vs Final

Posted to the Artima forum following this interview with Anders Hejlsberg about the ‘virtual’ keyword in C# compared to Java’s ‘final’

By making methods final by default, and having to explicitly state which ones can be overridden, you are forcing developers to try and anticipate all possible future uses of the code they write.

It encourages a sort of protectionist attitude that says ‘You’re not smart enough to understand how my code works, so I’m going to only let you override the bits that I choose to allow’.

I write code to be useful, and if someone sees a use for it that I didn’t anticipate, by overriding a method, then thats a good thing and should be lauded, not repressed.