468,170 Members | 2,152 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,170 developers. It's quick & easy.

How to seperate the business logic from the UI

I'm coming from Borland C++ and am "somewhat" new to C#, but very seasoned
in C++.

I'm looking for a specific feature that Borland had that I can't seem to
find in C#.

In Borland that feature is a DataModule.
This is a place where you place all of your Database and business logic.
This logic can then be "bound" to your UI by use of Borland Datasource
components.

This provides a very clean design and clear seperation of UI and data.
It also allow you to use the business logic without the UI if the need
arises.

Does C# offer something like this?

If not, how would you seperate your business logic from the UI?

Thanks


Sep 1 '06 #1
6 3579
Databinding. For example you can have List<Tcontaining all your biz
collection or objects. A DataViewGrid, for example can take that List<Tto
display it and update the object(s) in the list.

--
William Stacey [MVP]

"Relaxin" <me@yourhouse.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
| I'm coming from Borland C++ and am "somewhat" new to C#, but very seasoned
| in C++.
|
| I'm looking for a specific feature that Borland had that I can't seem to
| find in C#.
|
| In Borland that feature is a DataModule.
| This is a place where you place all of your Database and business logic.
| This logic can then be "bound" to your UI by use of Borland Datasource
| components.
|
| This provides a very clean design and clear seperation of UI and data.
| It also allow you to use the business logic without the UI if the need
| arises.
|
| Does C# offer something like this?
|
| If not, how would you seperate your business logic from the UI?
|
| Thanks
|
|
|
|
Sep 1 '06 #2
You do this by creating a new Project (class library)
for each layer that you need. If you have 3 layers
then you will need 3 class libraries (3 .dlls).

A typical 3-5 layer application will look like this:

YourApp.Business.dll
YourApp.BusinessEntities.dll
YourApp.DalSql.dll
YourApp.Gui.WinForms.exe
YourApp.Gui.ASPnet.exe

Very clean seperation,
all code for Biz Logic is in Business.dll, etc.
In this case there are two UI programs,
they both can use the supporting .dlls. You
do this by adding a reference to the .dlls
needed in the .exe projects.

As for business entity layer you can
use either datasets *or* custom business
objects (c# classes). Datasets are easier
but classes are much more powerful.

Russell Mangel
Las Vegas, NV

This book is very good, it is slanted towards datasets, but does have
considerable information on Custom Business Objects.
Brian does an excellant job explaining how to build a layered application.

Data Binding with Windows Forms 2.0: Programming Smart Client Data
Applications with .NET (Microsoft Net Development Series)
by Brian Noyes
http://www.amazon.com/Data-Binding-W...e=UTF8&s=books

Another good resource for Custom Business Objects is: (no datasets).

Expert C# 2005 Business Objects, Second Edition by Rockford Lhotka
http://www.amazon.com/Expert-2005-Bu...e=UTF8&s=books
Sep 1 '06 #3
To separate the Db code from UI code in the designer, you can use "partial
class" (.NET 2.0) to define a new ".cs" file that will contain only your Db
Logic. Partial class is a way to split a class in multiple files.

Example :

File for UI : DbForm1.cs

Partial class DbForm1

{

//..do things

}

File for Db: DbForm1-DB.cs

Partial class DbForm1

{

//..do things

}

Steph.


"Relaxin" <me@yourhouse.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
I'm coming from Borland C++ and am "somewhat" new to C#, but very seasoned
in C++.

I'm looking for a specific feature that Borland had that I can't seem to
find in C#.

In Borland that feature is a DataModule.
This is a place where you place all of your Database and business logic.
This logic can then be "bound" to your UI by use of Borland Datasource
components.

This provides a very clean design and clear seperation of UI and data.
It also allow you to use the business logic without the UI if the need
arises.

Does C# offer something like this?

If not, how would you seperate your business logic from the UI?

Thanks


Sep 1 '06 #4
Thus wrote TheSteph,
To separate the Db code from UI code in the designer, you can use
"partial class" (.NET 2.0) to define a new ".cs" file that will
contain only your Db Logic. Partial class is a way to split a class
in multiple files.
One should rather design and implement a proper data access layer...
--
Joerg Jooss
ne********@joergjooss.de
Sep 2 '06 #5
One should rather design and implement a proper data access layer... --
Uhm..yea, thanks.
Not sure how that answers my question.
Sep 2 '06 #6
Hi,

I am not an expert nor know about Borland Datasource. Here is what I do
in my multi later programming. I use MVP pattern (look at MS pattersn
and practices). Depending on what kind of database you are using, use
ER mapping tool seperate the data layer from data layer and put all
your bussiness login in the upper layer. This is a very clean way to
seprate the the things out for scalability and mantence.

Thanks.

Relaxin wrote:
One should rather design and implement a proper data access layer... --
Uhm..yea, thanks.
Not sure how that answers my question.
Sep 2 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

25 posts views Thread by Stuart Hilditch | last post: by
7 posts views Thread by Rob R. Ainscough | last post: by
16 posts views Thread by MS newsgroup | last post: by
25 posts views Thread by Penelope Dramas | last post: by
2 posts views Thread by Chris Zopers | last post: by
9 posts views Thread by SAL | last post: by
reply views Thread by kamranasdasdas | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.