As a rule of thumb, is it good practice to abstract application
functionality from the form code behind in a c# winforms app? I have a
single form application, but I'm not sure where I should be doing my main
processing, if I should be working with the Form class instance or creating
an "engine" class and doing everything there? Are there any general
guidelines?
Hope that makes sense... ;) 11 1236
Hello Steve,
it's a good practice to absctact app functionality from the everything, not
form :)
U need to extract interface from yout func code.
by the way, it the FW2.0 forms already separated from code
S> As a rule of thumb, is it good practice to abstract application
S> functionality from the form code behind in a c# winforms app? I have
S> a single form application, but I'm not sure where I should be doing
S> my main processing, if I should be working with the Form class
S> instance or creating an "engine" class and doing everything there?
S> Are there any general guidelines?
S>
S> Hope that makes sense... ;)
S>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
"Michael Nemtsev" <ne*****@msn.com> wrote in message
news:43***************************@msnews.microsof t.com... Hello Steve,
it's a good practice to absctact app functionality from the everything,
not form :) U need to extract interface from yout func code. by the way, it the FW2.0 forms already separated from code
S> As a rule of thumb, is it good practice to abstract application S> functionality from the form code behind in a c# winforms app? I have S> a single form application, but I'm not sure where I should be doing S> my main processing, if I should be working with the Form class S> instance or creating an "engine" class and doing everything there? S> Are there any general guidelines? S> S> Hope that makes sense... ;) S> --- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour
"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche
Hi Michael, thank you for the reply
I'm not sure what you mean here "it the FW2.0 forms already separated from
code"
can you elaborate please?
"Steve" <ss*@sss.com> a écrit dans le message de news:
%2****************@TK2MSFTNGP11.phx.gbl...
| As a rule of thumb, is it good practice to abstract application
| functionality from the form code behind in a c# winforms app? I have a
| single form application, but I'm not sure where I should be doing my main
| processing, if I should be working with the Form class instance or
creating
| an "engine" class and doing everything there? Are there any general
| guidelines?
You are heading in a very good direction here :-)
In theory, you should be able to build and test all your business classes
without any UI at all; using NUnit to buid your test framework. Then once
you have proven that your business classes are "bug-free", you can start to
think about how you want to display the properties of instances of those
classes.
Certainly, you should separate you app functionality from you UI; you might
also consider separating your app functionality from your database
connectivity; see some articles on OPFs (Object Persistence Frameworks) on
my website www.carterconsulting.org.uk they are targetting Delphi but the
principles are the same.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer
"Joanna Carter [TeamB]" <jo****@not.for.spam> wrote in message
news:O0*************@tk2msftngp13.phx.gbl... "Steve" <ss*@sss.com> a écrit dans le message de news: %2****************@TK2MSFTNGP11.phx.gbl...
| As a rule of thumb, is it good practice to abstract application | functionality from the form code behind in a c# winforms app? I have a | single form application, but I'm not sure where I should be doing my
main | processing, if I should be working with the Form class instance or creating | an "engine" class and doing everything there? Are there any general | guidelines?
You are heading in a very good direction here :-)
In theory, you should be able to build and test all your business classes without any UI at all; using NUnit to buid your test framework. Then once you have proven that your business classes are "bug-free", you can start
to think about how you want to display the properties of instances of those classes.
Certainly, you should separate you app functionality from you UI; you
might also consider separating your app functionality from your database connectivity; see some articles on OPFs (Object Persistence Frameworks) on my website www.carterconsulting.org.uk they are targetting Delphi but the principles are the same.
Joanna
-- Joanna Carter [TeamB] Consultant Software Engineer
Thank you for the great response Joanna!
I'm glad you mention Data access, I was just designing that (on paper) and
will be using MS Access at first, then if all goes well moving to SqlServer,
so I figured that a data access class for each provider inheriting a common
interface would make the transition smoother in the future. I was also
considering the same approach for the UI, currently it's a desktop client,
but I would like to offer a web client later.
I will check out your links.
I used exclusively sql for a long time, so I always used SqlConnection,
etc... Then I discovered quite a while back the interfaces IDbConnection,
etc., which changed my entire outlook on db access. It does take some extra
work, sometimes (like when you actually need to instantiate a connection)
but works so much better and is database "independent" (almost).
Scott
"Steve" <ss*@sss.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl... "Joanna Carter [TeamB]" <jo****@not.for.spam> wrote in message news:O0*************@tk2msftngp13.phx.gbl... "Steve" <ss*@sss.com> a écrit dans le message de news: %2****************@TK2MSFTNGP11.phx.gbl...
| As a rule of thumb, is it good practice to abstract application | functionality from the form code behind in a c# winforms app? I have a | single form application, but I'm not sure where I should be doing my main | processing, if I should be working with the Form class instance or creating | an "engine" class and doing everything there? Are there any general | guidelines?
You are heading in a very good direction here :-)
In theory, you should be able to build and test all your business classes without any UI at all; using NUnit to buid your test framework. Then once you have proven that your business classes are "bug-free", you can start to think about how you want to display the properties of instances of those classes.
Certainly, you should separate you app functionality from you UI; you might also consider separating your app functionality from your database connectivity; see some articles on OPFs (Object Persistence Frameworks) on my website www.carterconsulting.org.uk they are targetting Delphi but the principles are the same.
Joanna
-- Joanna Carter [TeamB] Consultant Software Engineer
Thank you for the great response Joanna!
I'm glad you mention Data access, I was just designing that (on paper) and will be using MS Access at first, then if all goes well moving to SqlServer, so I figured that a data access class for each provider inheriting a common interface would make the transition smoother in the future. I was also considering the same approach for the UI, currently it's a desktop client, but I would like to offer a web client later.
I will check out your links.
"Scott" <sd******@gmail.HEY_YOU.com> wrote in message
news:OK**************@TK2MSFTNGP14.phx.gbl... I used exclusively sql for a long time, so I always used SqlConnection, etc... Then I discovered quite a while back the interfaces IDbConnection, etc., which changed my entire outlook on db access. It does take some
extra work, sometimes (like when you actually need to instantiate a connection) but works so much better and is database "independent" (almost).
Scott
"Steve" <ss*@sss.com> wrote in message news:%2***************@TK2MSFTNGP15.phx.gbl... "Joanna Carter [TeamB]" <jo****@not.for.spam> wrote in message news:O0*************@tk2msftngp13.phx.gbl... "Steve" <ss*@sss.com> a écrit dans le message de news: %2****************@TK2MSFTNGP11.phx.gbl...
| As a rule of thumb, is it good practice to abstract application | functionality from the form code behind in a c# winforms app? I have
a | single form application, but I'm not sure where I should be doing my main | processing, if I should be working with the Form class instance or creating | an "engine" class and doing everything there? Are there any general | guidelines?
You are heading in a very good direction here :-)
In theory, you should be able to build and test all your business
classes without any UI at all; using NUnit to buid your test framework. Then
once you have proven that your business classes are "bug-free", you can
start to think about how you want to display the properties of instances of
those classes.
Certainly, you should separate you app functionality from you UI; you might also consider separating your app functionality from your database connectivity; see some articles on OPFs (Object Persistence Frameworks) on my website www.carterconsulting.org.uk they are targetting Delphi but
the principles are the same.
Joanna
-- Joanna Carter [TeamB] Consultant Software Engineer
Thank you for the great response Joanna!
I'm glad you mention Data access, I was just designing that (on paper)
and will be using MS Access at first, then if all goes well moving to SqlServer, so I figured that a data access class for each provider inheriting a common interface would make the transition smoother in the future. I was also considering the same approach for the UI, currently it's a desktop
client, but I would like to offer a web client later.
I will check out your links.
Hi Scott,
From what I have read, the IDbConnection is an interface and I futher
understood that interfaces don't have implementation. So can you explain a
bit more how you would use this interface?
Thanks,
Steve
"Steve" <ss*@sss.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... As a rule of thumb, is it good practice to abstract application functionality from the form code behind in a c# winforms app? I have a single form application, but I'm not sure where I should be doing my main processing, if I should be working with the Form class instance or
creating an "engine" class and doing everything there? Are there any general guidelines?
Hope that makes sense... ;)
I'm realizing that I have a ton of questions about architecture design, lots
of ideas that I want to bounce around. Do any of you know of an appropriate
news group for such a discussion?
Steve wrote: As a rule of thumb, is it good practice to abstract application functionality from the form code behind in a c# winforms app? I have a single form application, but I'm not sure where I should be doing my main processing, if I should be working with the Form class instance or creating an "engine" class and doing everything there? Are there any general guidelines?
Hope that makes sense... ;)
Yes it is a good practice. There are several caveats though. The
traditional c++ way has been to set up interfaces for everything. I
tend to use abstract classes/methods and virtual methods which gives you
everything interfaces give you plus ability to write code common to all
implementation just once. In addition, virtual classes allow you to
have fall back code (i.e. if the derived code doesn't implement it, the
app relies on the base implementation).
It is a good practice, no doubt. However, as you've probably found out,
it takes more setup time to do your app correctly. I've been in many
situations where the client needed the app yesterday and nothing else
mattered, so my principles had to stand aside for the purpose of expediency.
Regards
"Steve" <ss*@sss.com> a écrit dans le message de news:
e$**************@TK2MSFTNGP09.phx.gbl...
| From what I have read, the IDbConnection is an interface and I futher
| understood that interfaces don't have implementation. So can you explain
a
| bit more how you would use this interface?
PMFJI. we use interfaces a lot; they are essentially a contract that
guarantees that any class that implements that contract will provide the
declared properties and methods.
Declaring an interface allows you to state the services that your
data-access layer or UI will provide, but doesn't state *how* those services
will be provided. Thus you can write an Access OPF behind the interface and
also a SQL Server OPF behind the same interface.
Your application code always talks to the same interface, but you can change
the implementing class simply by deciding which OPF to instantiate.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer
I use the interfaces like this (this code is just an example and isn't
tested)
I defined a class with static members "DbUtilties" which handles the actual
instantiation of a connection, since this cannot be done using the interface
alone. For simplicity, I defined an enum with the list of "supported"
databases, DbType.
IDbConnection conn = DbUtilities.GetConnection(DbType.SQL);
IDbCommand cmd = conn.CreateCommand();
....
From here it is pretty obvious. The only catch to this kind of thing is
that the syntax of the SQL stmt themselves varies slightly. MySql requires a
';' at the end of each statement. (since this doesn't affect microsoft sql,
i add the semicolon to all sql statements).
Scott
"Scott" <sd******@gmail.HEY_YOU.com> wrote in message
news:O1*************@TK2MSFTNGP15.phx.gbl... I use the interfaces like this (this code is just an example and isn't tested)
I defined a class with static members "DbUtilties" which handles the
actual instantiation of a connection, since this cannot be done using the
interface alone. For simplicity, I defined an enum with the list of "supported" databases, DbType.
IDbConnection conn = DbUtilities.GetConnection(DbType.SQL); IDbCommand cmd = conn.CreateCommand(); ...
From here it is pretty obvious. The only catch to this kind of thing is that the syntax of the SQL stmt themselves varies slightly. MySql requires
a ';' at the end of each statement. (since this doesn't affect microsoft
sql, i add the semicolon to all sql statements).
Scott
Got it, Scott, thanks for the explanation. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jeff Levinson [mcsd] |
last post by:
I'm an architect for a very large fortune 100 company and
we still struggle with the best balance. However, I use a
couple of simple guidelines that have worked very well
for me in almost all...
|
by: Saurabh |
last post by:
I require urgently guidelines to aid in deciding whether to go for a FAT Client Application or a Client-Server Application model. Like Pros and Cons related to the Performance issue in both the above...
|
by: Michael Conroy |
last post by:
I like the MS Money and InstallShield interfaces (at least, I like the
hypertext, Web based appearance.) I would like to provide such a front end
to my Windows Form application. However, I'm...
|
by: Silent Ocean |
last post by:
Hi
1. I am in process of designing N-Tier Application using ASP.NET. Can
anyone guide me the right material or microsoft guidelines document
which I can used in designing the N-Tier application....
|
by: Annie |
last post by:
hello guys,
I have a GUI, Business Object layer and data layer.
What is the best way to handle errors in these layers?
Do I need to catch errors in all these layers? Or simply as all the...
|
by: jensen bredal |
last post by:
Hello,
I need to build a new web system. It is required that i use SOA .
Can someone tell me briefly what that means in practise. I have read
some rather abstract documents, describing the idea...
|
by: Silent Ocean |
last post by:
Hi
1. I am in process of designing N-Tier Application using ASP.NET. Can
anyone guide me the right material or microsoft guidelines document
which I can used in designing the N-Tier application....
|
by: MarkusJNZ |
last post by:
Hi, we have some datafeeds which pull info from external sources.
Unfortunately, we have to use screen scraping as there are no XML
feeds. The data feeds are located in a variety of different...
|
by: ludwig_stuyck |
last post by:
I'm in the process of designing a Service Oriented Architecture. At
the moment I based the design on the Web Service Software factory
guidelines - so a services layer, business layer and resource...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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: 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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |