Thursday, February 03, 2005

Peek .NET 2005: Default instance for forms

Looks like default instance are back into forms again to give Visual Basic 6.0 developers migrating to Visual Basic.NET the familiar way to reference forms without actually creating instances.
Dim frm as New MyForm
frm.Show()

can be done in VB.NET 2005 simply as
MyForm.Show()

This will show the default instance of MyForm. Personally I don't like this feature much as this might lead to some bad practices. I guess implementing a Singleton pattern is much more cleaner and makes more sense. But since it is there in VB.NET 2005 maybe some developers do prefer this method...

No comments: