tags:

views:

271

answers:

12

This is pure curiosity...

Most 'professionals' will likely never use "Form1" as a valid class name in their Windows Forms projects. I usually end up renaming it to MainForm.

What do you do?

Edit: For those of you that use hungarian notation (frmMain) - why? I don't think it would still be considered a standard practice... is it?

+2  A: 

frmMain is my typical choice.

statenjason
hungarian notation - yuck!
Luke Schafer
@Luke - I agree in the general sense (i.e. strString irks me), but I do find that using this for UI elements (txtTextbox) *can* be useful, in moderation. That said, I don't feel the need to use it for form names.
AgentConundrum
Yuck indeed. Hungarian notation should be used to solve problems, not just as a habit. Modern IDEs now let you hover your mouse over a variable and see its type if you need to, but if you name a variable well you won't even need that. This is a really long article but details exactly how to use Hungarian notation to actually gain an advantage, rather than just adding unnecessary lowercase letters everywhere: http://www.joelonsoftware.com/articles/Wrong.html
Ricket
Been awhile since I've made a winform app, and most of them were for an (old, mind you) instructor that enforced it. The WPF realm is where I reside these days with a "MainWindow" and "<Name>Views"
statenjason
@AgentConundrum - yeah, that's what most people seem to say which is fine. I'd just rather steer clear of it. The true meaning of Apps Hungarian (hungarian notation) was all about the 'kind of' object rather than the 'type of', but this has been lost to antiquity... I think Joel even wrote about this once besides the article Ricket posted
Luke Schafer
@Luke - You could argue, though likely unsuccessfully, that simply having a prefix at all satisfies your 'kind of' requirement. Variables with a prefix are a 'kind of' UI element, and those that don't aren't. Out of curiosity, do you make any distinction at all between your UI names and your method variables? You need some way to validate your input and both the local variable and the UI variable could reasonably be named, for example, 'username' so how do you distinguish UI variables (which generally shouldn't be modified) and 'temp' variables which are used for validation, etc.?
AgentConundrum
+1  A: 

frmMain for MDI applications. I don't bother changing it for single-form apps..

David Stratton
I do the same :D
yelinna
A: 

I usually name my main form to keep in line with the project. For instance, I'm (slowly) writing a small application that was intended to help manage peer reviews at my previous employer. My main form in this project was simply called ReviewManager.

AgentConundrum
+1  A: 

I often use some variation of ApplicationShellForm.

This is because it's really, in most of my "real" work, nothing more than a thin shell where I inject the real behavior at runtime. My "main form" usually has very little in it, in and of itself.

That being said - I'd always call it something based on its behavior. What does your main form or application do? That's what would determine what I'd call it, if I wasn't building everything around dependency injection and trying to maintain some separation of concerns.

Reed Copsey
+8  A: 

{AppName}Form.

McWafflestix
A: 

Generally I rename it to frmMain, similar to statenjason. But if it has a different purpose, or is being used as a prototype that will get rolled into a larger project I will rename it to something more descriptive. So Form1 might become frmSomeComplexTest, or frmSomeMethodOutputTester.

Charles Y.
A: 

I don't change it unless a different Form ends up being the main one. In which case, I'll rename that one Form1.

Form1, FormMain, it's essentially the same thing. It's not like your users will ever know/care, nor will it be confusing for someone maintaining your code.

pyrochild
+11  A: 

MainForm. I loathe Hungarian notation, and FxCop complains about it in any case, so MainForm, OkButton, AboutDialog, etc.

John Saunders
@Downvoter: please say why you downvoted. There's no way to improve the answer if I don't know what problem you find in it.
John Saunders
+2  A: 

I prefer MainForm, not FormMain. Using Form as a prefix breaks alphabetical order!

emddudley
+3  A: 

Dennis. My form's name is Dennis.

ajh1138
A: 

If my program is named Fred, and its UI lives in a form, FredForm is what that form gets called. The moment there's more than one form, it gets promoted to FredMainForm, so long as it's actually still the centerpiece of the UI.

Robert Rossney
A: 

frmMain for single form apps, MDIMain for MDI apps. I name the project specific to the business purpose and let the business decide the form's text.

Beth