Tuesday, November 30, 2004

New language features

There's an overview of the new language features in VB.NET 2.0 on MSDN.

Looks very interesting. There are some really cool features in there, like:

  • XML Commenting
    I've already used his to a certain extent with the VBCommenter powertoy and find it quite cool. I find it really helpful. I'm a bit of an inconsistent commenter, and this adds a bit of structure and a bit of consistency to my commenting. And I'm a cheap toy whore. It's really handy to use it with NDoc for making nice MSDN-style documentation as well, though.

  • TryCast
    Not too much to say about this, apart from cool! What's that you say? No need to wrap all my casts into a try/catch block? No need to typecheck every object that gets passed into my methods? I'll have some of that!

  • Operator Overloading
    Ah yes. Operator overloading. Very handy. Eliminate whole swathes of code with a single operator. Sweet!
It's not all good, though. There are a couple of things in there that, certainly at the moment, I can see being really heavily abused.

Some of them include:
  • Partial Types
    What? Split the same class over several files? Although I can see some potential for this being quite useful, I also envisage people using it to implement some sort of weird file-based architecture to their code. Namespaces? We don't need no stinking namespaces! I have visions of something like this:
    File: SavingMethods.vb
    Partial Class Widget
    Public Sub SaveToDB(Thingy as IWidget)
    'Lots of DB Code here
    End Sub
    End Class

    Partial Class InheritedWidget
    Public Sub SaveAsXML(Thingy as IWidget)
    'Lots of XML Code here
    End Sub
    End Class

    Note to self: You've said it now. I can guarantee you'll catch yourself doing it at some point. Remember to slap yourself silly for it when you do!

  • Default Instances for forms
    Yes. Here's an idea. Let's try and make VB.NET just like VB6. Forms you don't have to instantiate? Yeah! I'm sure it fits in nicely with the rest of the entire sodding language. Do I want an exception to that rule? Of course I do! I want to have to instantiate every reference type except one. I'm sure I'll never trip myself up.(</sarcasm>)
OK, so I don't have to use any of the stuff I don't want to. If I want to put my classes all together, then I can (and probably will). If I want to skip the line "Dim theform as new Form1" then I will.

It's just some things that were occurring to me as I was reading about it. All in all, though, I'm really looking forward to getting to play with VB.NET 2.0, and VS 2005. Sad, I know.

Oh yeah, and another note to self: If you're going to have an image illustrating how XML Comments appear in intellisense, you'd better have an image that shows the comments being shown by intellisense.

Sorry about the length. It was just on my mind and wanted to get off.

No comments: