473,799 Members | 3,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1506
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.co m

"Simon Harvey" <sh856531@micro softs_free_emai l_service.com> wrote in message
news:OV******** ******@TK2MSFTN GP11.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
1551
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 there by using LoginForm.ShowDialog() . well the log in form appears all right but I cant seem close it ... When I minimize the main form it is there , although I have used Close(). Help any one ?
0
352
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 with three objects a < b , b < c means a < c I studied Quick Union Find algorithms a bit and if I understood them correctly, once the user gives the input setting the rules/connection between objects, the algorithm will give as output the result...
0
310
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 with three objects a < b , b < c means a < c I studied Quick Union Find algorithms a bit and if I understood them correctly, once the user gives the input setting the rules/connection between objects, the algorithm will give as output the result...
33
1806
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 completely new to programming and using a Mac and would like some input as to where to begin a career in programming. I know this is probably a somewhat undefined question, but would appreciate you input/advice. Thanks.
9
1610
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 user/password on entering the password the form will check the local file to authenticate, (encrypted file) then it will return true in (loadLoginForm) else false if the used clicked cancel based on the that input I have to load the main form....
6
1323
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 application starts up after a successfull reboot. However, my application needs to read a text file in the same directory as the executable, and for some reason, it cannot access this file when the program is started by the Run registry key. If I...
5
1560
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 view and the view logic distinct. Is there a strong argument for combining these in one file? (It may just feel wrong to me because of years of J2EE/JSP programming where you always keep them seperate.)
0
1482
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 the computer. I have two other user accounts on the same computer and they work fine and launch on startup. Any ideas why this is happening? This occured after I installed and ran PC Tools Spyware Doctor but I can't see any reference to it in...
6
1415
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 server via a webservice I have written the code to do all of these things. Now I want to put them into a startup form. I want to load my main form, but from the main form I want to call a splash screen with an animation on it that will cycle...
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10243
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.