Omer van Kloeten's .NET Zen

Programming is life, the rest is mere details

News

Note: This blog has moved to omervk.wordpress.com.

Omer van Kloeten's Facebook profile

Omer has been professionally developing applications over the past 8 years, both at the IDF’s IT corps and later at the Sela Technology Center, but has had the programming bug ever since he can remember himself.
As a senior developer at NuConomy, a leading web analytics and advertising startup, he leads a wide range of technologies for its flagship products.

Get Firefox


powered by Dapper 

.NET Resources

Articles :: CodeDom

Articles :: nGineer

Culture

Projects

Being Explicit

A discussion with a friend who works mainly with Java has come to the old case of virtual-by-default vs. final-by-default.

When I come to declare a method, I can decide whether I want derived classes to be able to override it. Java does this by default, which kind of sucks because it opens up a way for people to override code you haven't intended on letting them override, just because you forgot to mark the method as final. C# makes all methods final by default, which kind of sucks, since you can forget to make a method virtual and thus limit the deriving class from doing things it could have done if you had marked the method as virtual.

So why not take a third road? Why not just be constantly explicit about what you want to do? I think all methods declared in C# should be required to have a 'sealed' or 'virtual' (or 'override') modifier on them. This way, you would never be able to get away with not making the decision whether derived classes can override a method or not.

But that's just a thought... :)

Posted: Nov 15 2004, 08:02 PM by Omer van Kloeten | with 5 comment(s)
Filed under:

Comments

No Comments