By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,656 Members | 1,327 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,656 IT Pros & Developers. It's quick & easy.

Quick question on startup logic

P: n/a
Hi all,

I was wondering how most developers handle the initial startup of their
Windows Forms applications?

When you make an application in Visual Studio, the IDE places Main in the
form that VS makes for you. When I make my applications I sometimes feel
uneasy about leaving the startup logic in the Form - it sort of seems the
wrong place for it. I'm by no means an expert on such things (which is why
I'm writing this post), but it seems that a Form, as part of the UI Layer,
is the wrong place to start an application.

I have tended to try and make a 'main' class that contains the Main() method
and controls the startup of application wide services from there. Thats
causing me some problems though because I don't fully understand what is
best practice when it comes to architecting medium sized application.

So, my question is - where should startup logic go? Am I right to be
suspicious of putting this sort of global logic in the UI layer, or am I way
off the mark and shouldnt be worrying about it?

Your advice as always, would be greatfully received

Many thanks everyone

Simon
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Simon,

I think you are on the right track. For any kind of configuration, etc,
etc, a separate class seems (to me) to be the right way to go. Any class
can have a Main method that is used as the entry point (it doesn't even have
to be called Main, it just has to have a certain signature). For
large-scale apps, I think that it is better to have it in another class to
separate the UI from the buisness logic. Then, you can do your startup, and
pass along any information the form needs to it when you feel it is
appropriate. Also, before the form is shown, this is the perfect place to
do things such as check dependencies, pre-load data, etc, etc (if that is
what you are trying to achieve).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Simon Harvey" <sh856531@microsofts_free_email_service.com> wrote in message
news:OV**************@TK2MSFTNGP11.phx.gbl...
Hi all,

I was wondering how most developers handle the initial startup of their
Windows Forms applications?

When you make an application in Visual Studio, the IDE places Main in the
form that VS makes for you. When I make my applications I sometimes feel
uneasy about leaving the startup logic in the Form - it sort of seems the
wrong place for it. I'm by no means an expert on such things (which is why
I'm writing this post), but it seems that a Form, as part of the UI Layer,
is the wrong place to start an application.

I have tended to try and make a 'main' class that contains the Main() method and controls the startup of application wide services from there. Thats
causing me some problems though because I don't fully understand what is
best practice when it comes to architecting medium sized application.

So, my question is - where should startup logic go? Am I right to be
suspicious of putting this sort of global logic in the UI layer, or am I way off the mark and shouldnt be worrying about it?

Your advice as always, would be greatfully received

Many thanks everyone

Simon

Nov 15 '05 #2

P: n/a
Thanks Nicholas

Simon
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.