The names like
buttonCreateIncident_Click
look ugly and violate Microsoft naming conventions. Yes, I know it is generated by Microsoft, so what? They are ugly and violate them. All auto-generated names imply you rename them semantically. In this way, you will indicate they were attended. See FxCop — it won't allow such names.
Better yet, never allow auto-generate events. Write them manually: it's faster (overall) and provides supportable code. Do this:
MyButton.Click += (sender, eventArgs) => {
};
If you have to use C# v.2 you cannot use lambda, so you have to use this:
MyButton.Click += delegate(object sender, System.EventArgs eventArgs) {
;
Anyway, this is much better than your auto-generated code.
I also would advice to split all your code in a separate file. The form declaration is partial, so you can add another part in a separate file and isolate your code from auto-generated one.
Look at your "
Domain
", "
(char)92
", and especially
""
. You use so called immediate constant 92, that is, hard-coded. This is bad. Never do it in code. Such stuff belongs in resources (data, such as configuration files in some other cases). To simplify that, you can put all your constants in a separate static class, where you can explicitly declare them as constant. Don't use immediate except some trivial cases such as null, 0 and 1 (but not "", use
string.Empty
).
You should
always clean-up you
using
clauses. Visual Studio has "Organize using" -> "Remove unused using", use it. It can be not enough. Go to your project's References and clean the first. The template usually auto-generate a lot of unused staff. Better add references when it is really needed, in order to support clean code.
—SA