5 Replies - 2789 Views - Last Post: 31 January 2011 - 07:53 AM

Poll: Default Form Instances (7 member(s) have cast votes)

Good or Bad?

  1. Good (1 votes [14.29%] - View)

    Percentage of vote: 14.29%

  2. Bad (6 votes [85.71%] - View)

    Percentage of vote: 85.71%

Vote Guests cannot vote

#1 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon

Reputation: 2290
  • View blog
  • Posts: 9,529
  • Joined: 29-May 08

Default Form Instance VS New Instance Of Form

Post icon  Posted 26 January 2011 - 01:29 PM

Default Form Instance VS New Instance Of Form


Default Form Instance

Form2.Show


New Instance Of Form
Dim f2 As New Form2
f2.Show


Question to start you off.
What are the merits of each?
What are the disadvantages of each?

Begin

Is This A Good Question/Topic? 2
  • +

Replies To: Default Form Instance VS New Instance Of Form

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4751
  • View blog
  • Posts: 8,462
  • Joined: 08-June 10

Re: Default Form Instance VS New Instance Of Form

Posted 26 January 2011 - 03:08 PM

I think an obvious disadvantage is that it shares syntax with calling Shared properties/methods. It's very easy to get those things confused. The difference between Shared and instance is a hard enough concept to explain to new programmers when it's not being mixed up with a hidden instance.

I suppose an advantage is shorter syntax. But I personally refuse to use it when I'm using VB.NET.

I think I'm biased against it, because I had no idea it was even there for a while. I remember telling someone flat out that their code shouldn't even compile, and I was shocked when it did! Of course, it didn't work, but it compiled.

Actually, I'm curious how a default instance actually works. Is it instantiated upon execution, or the first time it's called, or every time it's called? If a form doesn't provide a default constructor, what happens?

Also, I suppose the good/bad relates to using the Default Instance?

This post has been edited by insertAlias: 26 January 2011 - 03:09 PM

Was This Post Helpful? 0
  • +
  • -

#3 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 448
  • View blog
  • Posts: 1,504
  • Joined: 28-April 09

Re: Default Form Instance VS New Instance Of Form

Posted 26 January 2011 - 03:28 PM

if you were going to open multiple instances of the form would it even be possible using the default instance?
Was This Post Helpful? 0
  • +
  • -

#4 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1256
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Default Form Instance VS New Instance Of Form

Posted 26 January 2011 - 04:00 PM

That usage of default form instances look really stank. :x

I prefer using the new instance method because it is more easily understood. When I first read the thread I thought that first example wouldn't compile.
Was This Post Helpful? 0
  • +
  • -

#5 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1719
  • View blog
  • Posts: 5,636
  • Joined: 25-September 09

Re: Default Form Instance VS New Instance Of Form

Posted 26 January 2011 - 05:03 PM

I think this was added later to help the VB6 people move up to VB.Net. If I remember correctly, in the first release of VB.Net, you could not use a forms default instance. If you remember, there was a lot of animosity when VB6 programmers started using VB.Net and things just didn't work like they thought it would. Hell, I was one of them. I actually struggled to move to .Net because of all the changes from my knowledge of VB6.

I actually think if MS would have stuck to their guns, people would have came around and learned the proper methods but I'm sure marketing had a lot to do with these types of decisions. We can increase sales if we'll succumb to their gripes.

I think the real problem is, the default instance is primarily how students are taught to access the form. Let alone all the other legacy methods from the VisualBasic namespace.
Was This Post Helpful? 0
  • +
  • -

#6 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Default Form Instance VS New Instance Of Form

Posted 31 January 2011 - 07:53 AM

once the default instance get disposed, it will surely cause a lot of problems
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1