Turn Off, find all, step around... default instances

lordofduct

Well-known member
Joined
Jun 24, 2010
Messages
71
Programming Experience
3-5
I'm using Visual Studio 2008 writing a Windows Forms project and I'd like to know a way to step around 'default instances' of forms.

I don't like default instances, they constantly get in my way, and working in a team it's causing some really annoying confusion about the object identity of which form is actual in focus at this moment. This means I need to go threw the entire project (big) and remove ALL references to any 'default instance' of a form. But this is difficult to do as there's no errors or anything, it basically requires me to search for every text of "MyFormType." and then checking if it's accessing a default instance and fix it like that.


It'd be nice if I could just turn it off or something so I could

1) easily find all erronous lines of code
2) avoid the accidental use of it in the future by anyone on the team




[edit]
found a hack way of accomplishing half of what I want... in the constructor method require any number of parameters (they can even be optional, which is cool), and the project will then cry out about any default instance.
 
Last edited:
I would think that finding all usages by searching for "MyFormType." would be faster than editing each constructor and then looking for errors. Really, does you team have no coding guidelines? The default instance is accessed using the class name and variables should generally not have the same name as their type, so surely every instance you find that way will be a usage of a default instance.

As for "accidental" usage, again, how can a team with enforced coding guidelines ever accidentally use a default instance? Just tell your people: DO NOT USE DEFAULT INSTANCES.
 
Back
Top