473,325 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Quick question on startup logic

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
2 1488
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
Thanks Nicholas

Simon
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: msnews.microsoft.com | last post by:
Hi, What I am trying to do is create a log in form (in MDI application Using VB.NET) I have tried moving the application's startup logic into a separate class and create the Log in form from...
0
by: aredo3604gif | last post by:
The user can dynamically enter and change the rule connection between objects. The rule is a "<" and so given two objects: a < b simply means that b < a can't be set, also it must be a != b. And...
0
by: aredo3604gif | last post by:
The user can dynamically enter and change the rule connection between objects. The rule is a "<" and so given two objects: a < b simply means that b < a can't be set, also it must be a != b. And...
33
by: earthlinkmail | last post by:
....you experienced programmers of C; did you start with C? What course of study did you pursue to get to where you are today? Would you suggest starting with REALbasic first for a n00b? I am...
9
by: CSharpNewBie | last post by:
Hi I am creating a Winform application and I need help. Let me explain my problem This is what i do on startup, I create a form (a Login screen) at runtime and that will ask user to enter a...
6
by: Pyerwoh | last post by:
Greetings, I'm trying to have an application resume after a reboot, by making an entry into the Run registry key ("SOFTWARE\Microsoft\Windows\CurrentVersion\Run") . This works great, and my...
5
by: David Thielen | last post by:
Hi; Almost all of the Quick Starts show the code in the .aspx file inside a <script> instead of in a seperate .aspx.cs file. My instinct is that the code should be in a seperate file to keep the...
0
by: =?Utf-8?B?R2FyeSBNY0M=?= | last post by:
The quick launch tool bar doesn't load on startup in my user account. It works fine by clicking on the Task bar and selecting Quick Launch, but it doesn't seem to save the setting when I shut down...
6
by: John Wright | last post by:
During my program startup I need to check for a couple of things. 1. I need to check for network availability 2. I need to check for database connectivity 3. I need to check for access to the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.