473,387 Members | 1,844 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,387 software developers and data experts.

Separating WinForm from Logic

I have a WinForm class that has accumulated a tremendous amount of logic
code. Can anyone point me toward a good article on factoring logic code out
of a WinForm class?

Thanks,
--
Randy
May 26 '06 #1
4 3575
Randy,

I don't know of any books that specifically deal with the subject, but the
pattern is relatively simple:

Take all the busy business logic out of the Windows Form class and put it in
a separate, reusable class that can be used by any form. The windows form
can reference an instance of the other class and make the method calls. If
appropriate, the methods in the class can be made static so an instance isn't
required.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"randy1200" wrote:
I have a WinForm class that has accumulated a tremendous amount of logic
code. Can anyone point me toward a good article on factoring logic code out
of a WinForm class?

Thanks,
--
Randy

May 26 '06 #2
For books specific to this .. I might recommend Applying Domain Driven
Design and Patterns by Jimmy Nilsson
http://www.amazon.com/exec/obidos/tg...68202?v=glance (and some
related books Domain Driven Design and P of EAA (Fowler)

Cheers,

Greg Young
"randy1200" <ra*******@newsgroups.nospam> wrote in message
news:C8**********************************@microsof t.com...
I have a WinForm class that has accumulated a tremendous amount of logic
code. Can anyone point me toward a good article on factoring logic code
out
of a WinForm class?

Thanks,
--
Randy

May 26 '06 #3
It's pretty straight-forward. If code affects the User Interface directly,
such as changing the value in a text box, responding to a Click event or
other UI event, etc, it should be part of the code for the UI (form). If it
does not, it should be part of the business layer/classes. Now, where it
might get a little confusing is, for example, when an event handler does
something to a business object. Here, you want to use the event handler to
call a business method. In practice, it becomes only slightly more complex,
but that's the basic principle. Let your business layer do all the
manipulation of business data and enforcement of business rules. Let the UI
layer provide an interface between the User and the business classes/layer.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

This is, by definition, not that.

"randy1200" <ra*******@newsgroups.nospam> wrote in message
news:C8**********************************@microsof t.com...
I have a WinForm class that has accumulated a tremendous amount of logic
code. Can anyone point me toward a good article on factoring logic code
out
of a WinForm class?

Thanks,
--
Randy

May 28 '06 #4
Hi,
"randy1200" <ra*******@newsgroups.nospam> wrote in message
news:C8**********************************@microsof t.com...
I have a WinForm class that has accumulated a tremendous amount of logic
code. Can anyone point me toward a good article on factoring logic code
out
of a WinForm class?

It depends of how the code was written, even if you have a lot of controls
and events handlers if the logic is implemented in separated methods it may
be simpler, ITOH if the logic is inside all the handlers (posibly the same
code in more than one handler) or a handler call to one or more other
handlers, then you have a real mess in your hands :)

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
May 30 '06 #5

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

Similar topics

3
by: Skc | last post by:
My client's project consists of about 6 files maintenance programs that uses WinForm and grid for updates with lookup finders for each file. There is also a User file and security. There are...
8
by: Sunil Menon | last post by:
Dear All, We are developing applications in ASP.Net...in one of our applications we would like to use a GridControl...we have tried to use a Server-Side Grid control but found the speed to be an...
3
by: mca | last post by:
Hi everyone, I'm new to asp.net and i have a question about separating the html code from the programming code. i have an unknown numbers of entries in my table. I want to make a hyperlink...
1
by: RJ | last post by:
I have developed numerous WinForm based utilities in .NET, but I wanted to consider a WebForm UI for my next utility, which runs only inside a corporate intranet. I have done only minimal...
8
by: Jeff S | last post by:
Please note that this question is NOT about any particular pattern - but about the general objective of separating out presentation logic from everything else. I'm trying to "get a grip" on some...
5
by: Ronald S. Cook | last post by:
We have a Windows app which contains UI code and all classes that perform business logic and make calls to database stored procs (located on a database server - i.e. not local to the app). My...
0
by: dadizhu | last post by:
Hi, everyone. I ran into an UI freeze issue with threading and simplied the problem down to the following sample code. The logic is as follows: 1. The main UI thread creates a non-UI STA...
1
by: ffimbel | last post by:
Hi I would like to implement a single exe which could be invoked either as a standard windows form (no argument) or as a console app (when run with app.exe -nologo). I tried compiling the exe...
2
by: CSharper | last post by:
I have written a winform application not I need to run the same app in colsole mode without user interaction. Is there an easy way to do this? I have all the information available as input in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.