The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Design Flaw - C# or VB.NET ?

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
Michael Mello

Posts: 100
Nickname: knarf
Registered: May, 2004

Michael Mello is .NET Web Developer
Design Flaw - C# or VB.NET ? Posted: Jun 3, 2004 2:28 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Michael Mello.
Original Post: Design Flaw - C# or VB.NET ?
Feed Title: melloblog
Feed URL: http://www.thauvin.net/errorpage.htm?aspxerrorpath=/Default.aspx
Feed Description: .NET and Everything After.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Michael Mello
Latest Posts From melloblog

Advertisement
I was reading an interesting debate on Google Groups today titled, C# is too nitpicky?

The main discussion was about the design difference of VB.NET's Shared, and C#'s static members.  Shared and static are the same - they both belong to a type itself rather than to a specific object.  Knowing that, let's take a look at the possible design flaws in question.

VB.NET

Dim m as MessageBox
m.Show("Hello")



C#

MessageBox.Show("Hello")



The MessageBox.Show is a static (Shared in VB.NET) method that cannot be instantiated.  The difference here is that C# restricts the programmer from calling a static method from an instance of an object, and VB.NET does not. (Allowing you to do it either way)  

Now let's take a look at the two sides.

VB.NET Design Flaw

"The point is that a static member is not associated with any single instance of a class.  So, it
makes little sense to allow the calling of these methods through an instance.  In this instance, C# get's it right."


C# Design Flaw

"It's shared between /all/ instances, so calling these methods through an instance makes sense."

C# or VB.NET Design Flaw?

To reiterate, Shared/static members belong to a type, not a specific object.  The way VB.NET handles this is not intuitive, and therefore my vote is for VB.NET.

Read: Design Flaw - C# or VB.NET ?

Topic: James Newkirk Blog and NUnit.Whidbey Previous Topic   Next Topic Topic: Thoughts on the Dell FP2001

Sponsored Links



Google
  Web Artima.com   

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