The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Explicit interface implementation (and event handling)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Paul Vick

Posts: 783
Nickname: paulv
Registered: Aug, 2003

Paul Vick is a Tech Lead on Visual Basic at Microsoft Corp.
Explicit interface implementation (and event handling) Posted: May 13, 2004 11:36 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Paul Vick.
Original Post: Explicit interface implementation (and event handling)
Feed Title: Panopticon Central
Feed URL: /error.aspx?aspxerrorpath=/rss.aspx
Feed Description: a blog on Visual Basic, .NET and other stuff
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Paul Vick
Latest Posts From Panopticon Central

Advertisement

Christian notes some differences between the way C# and VB implement interfaces, prompting Peter to ask “Was it accidental or intentional?” The answer is: it was intentional. The exact thought process that lead to the current design is somewhat misty in my memory because it was so long ago, but here's kinds of how it went:

VB6 supported implicit event handling and interface implementation very similar to the way that C# does implicit interface implementation. You stated that you implement an interface and then you used a “magic name” to implement a method in the interface. When we were designing VB 2002, though, we wanted to allow people to handle multiple controls' events with a single handler. The magic name design for event handling would have effectively prevented that, because there was no reasonable “magic” name that could mean “hook me up to x.Click and y.Click.” (C# obviously doesn't have this problem since they don't support declarative event handling.) So we decided to drop magic naming for event handlers in favor of an explicit Handles clause that allowed multiple events to be handled.

Once we'd taken that step, we decided we liked the new explicitness of event handling and decided that it would work for interface implementation as well. It meant that we could get rid of clunky VB6-style magic names (i.e. “Sub IDisposable_Dispose(...)”) entirely and also meant that a single class member could implement multiple interface members, although so far I don't know of many places where that comes in super-handy (since most interfaces are, by nature, discrete from one another). Also, because it didn't rely on magic names, there was no chance that you might “accidentally” implement an interface member without realizing it.

So that's the story.

Read: Explicit interface implementation (and event handling)

Topic: Software Estimation webcast notes Previous Topic   Next Topic Topic: Simsa event:

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use