Best practice for multi tier apps?

R

rbrowning1958

Hello,

In the process of setting up my first multi tier app with .NET 2.0.
I'm sure this is a classic setup and if someone could confirm I have
the basics right would be much appreciated.

1. Application will have web and fat client access to the same sql
server database.
2. I want to use strongly typed datasets and business logic which is
shared between the web app and the fat client app.

I understand how to bind to an object data source etc. so my question
is where to place the common code. Would you have 4 separate projects
in the solution:

1. Web App
2. Fat client (windows GUI)
3. Business logic in its own project
4. Data access layer (the strongly typed data sets) in its own
project?

Or would it be more common to have the business logic and the data
access layer in class libraries and reference those from the web app
and fat client?


thanks

Ray
 
R

rbrowning1958

Hello,

In the process of setting up my first multi tier app with .NET 2.0.
I'm sure this is a classic setup and if someone could confirm I have
the basics right would be much appreciated.

1. Application will have web and fat client access to the same sql
server database.
2. I want to use strongly typed datasets and business logic which is
shared between the web app and the fat client app.

I understand how to bind to an object data source etc. so my question
is where to place the common code. Would you have 4 separate projects
in the solution:

1. Web App
2. Fat client (windows GUI)
3. Business logic in its own project
4. Data access layer (the strongly typed data sets) in its own
project?

Or would it be more common to have the business logic and the data
access layer in class libraries and reference those from the web app
and fat client?

thanks

Ray

Last sentence doesn't really make sense, does it? I meant in
separate .CS files rather than class libraries.

Thanks

Ray
 
A

Arne Vajhøj

rbrowning1958 said:
In the process of setting up my first multi tier app with .NET 2.0.
I'm sure this is a classic setup and if someone could confirm I have
the basics right would be much appreciated.

1. Application will have web and fat client access to the same sql
server database.
2. I want to use strongly typed datasets and business logic which is
shared between the web app and the fat client app.

I understand how to bind to an object data source etc. so my question
is where to place the common code. Would you have 4 separate projects
in the solution:

1. Web App
2. Fat client (windows GUI)
3. Business logic in its own project
4. Data access layer (the strongly typed data sets) in its own
project?

Makes sense to me.

Arne
 
S

sloan

////

I would agree as well. Well almost. Let me get to the agreement part
first.

When you have multiple presentation layers, its very important to have a
STRONG business layer.
Your validation should be done in the business layer.
On the web project, you might put some of the SIMPLE validation on the web
client (javascript) to avoid hitting the server,
but you want to have validation on the business layer as well.
(Ex....when adding a new employee, you need to make sure someone put in a
lastname and firstname....the business layer needs to validate
this...however, you may want to have the web client add some simple
javascript checks or simple things like "They put in at least 1 character
for a lastname, firstname".
But you do not want to have this validation in the presentation layer(s) as
copies. (think about maintenance when a rule changes).

My default setup goes like this:

Pres.Web1
Presentation.Winforms1
BusinessLogic
DataLayer
DataSets

If you follow my links...and find that "bird's eye" MS article I
mention.....the articles suggests (when using strong datasets) that they are
in their own assembly, and are kind of the "glue" which binds the other
layers together.
The DataLayer is used/consumed by the BusinessLayer. The PresentationLayer
knows about the BizLayer, but should NOT know (reference) the DataLayer.
In order to be able to pull that off, the PresentationLayer needs to know
about the strong datasets. Thus the seperation of the 2 assemblies
(DataLayer and DataSets).
Again, this is my opiniion and the opinion expressed at that article...when
doing strong datasets.

The DataLayer should return
IDataReaders
DataSets(strong usually)
void/nothing (ExecuteNonQuery type stuff)
scalar values.


Pres.Web1 (references BusinessLogic and DataSets)
Presentation.Winforms1(references BusinessLogic and DataSets)
BusinessLogic(references DataLayer and DataSets)
DataLayer ((references DataSets))
DataSets (references nothing)

You see how the PresLayer(s) do not know about the DataLayer. If you clump
up the DataLayer and the DataSets....you won't be able to this setup.
And thus you might be tempted to skip the business layer to get at data.
Which is a deficient idea in my opinion.

Anyway... That's one opinion.

I would also read the MS article because it does a good job of outlining the
pros and cons of using strong datasets vs strong business
objects/collections as well.

If I were starting a new project...I'd 90% pick strong business objects over
datasets these days. But that's me.

Good luck.
 
R

rbrowning1958

Hello and thanks for that. A clarification, please? You are proposing
separating the data layer from the datasets themselves. By datasets I
assume you mean the strongly typed dataSets VS will generate for me. I
can see the logic for this because the clients will need to see the
strongly typed datasets as they will be returned / processed by the
business layer (which the clients can see). By separating these the
clients cannot see the DAL directly. Clear on that.

So what do you put in the DataLayer? The table adapters? Now here's
where my ignoarance shows - if I'm using VS's dataset designer to
generate the datasets and table adapters how do I achieve this
separation? Although they are in separate namespaces aren't they all
generated in the same code file? Is there a way to change this, or do
you hand-code your table adapters?

Also, it's tedious hand coding the business objects - I'm on the
lookout for a tool which will generate basic business objects based on
a schema - www.likemedia.com looks good but their demo download
doesn't work at the moment so I've been unable to investigate. Any
other tools anyone woudl recommend?

Thanks

Ray
 
S

sloan

I don't know about how to do that...when you're doing the
//VS's dataset designer to
generate the datasets and table adapters how do I achieve this
separation?//
method.

...

http://msdn2.microsoft.com/en-us/library/ms978496.aspx

I'd read that article at least twice before writing any code.

If you download my samples, you'll see how I"m using to
EnterpriseLibrary.Data to bypass the auto generated stuff.

If your project is going to be around for a while...I'd dismiss the
autogenerated table adapters.

But that's me.

http://msdn2.microsoft.com/en-us/library/ms978496.aspx#boagag_deployment
"Deploying Business Entities"

But read the entire thing.



Hello and thanks for that. A clarification, please? You are proposing
separating the data layer from the datasets themselves. By datasets I
assume you mean the strongly typed dataSets VS will generate for me. I
can see the logic for this because the clients will need to see the
strongly typed datasets as they will be returned / processed by the
business layer (which the clients can see). By separating these the
clients cannot see the DAL directly. Clear on that.

So what do you put in the DataLayer? The table adapters? Now here's
where my ignoarance shows - if I'm using VS's dataset designer to
generate the datasets and table adapters how do I achieve this
separation? Although they are in separate namespaces aren't they all
generated in the same code file? Is there a way to change this, or do
you hand-code your table adapters?

Also, it's tedious hand coding the business objects - I'm on the
lookout for a tool which will generate basic business objects based on
a schema - www.likemedia.com looks good but their demo download
doesn't work at the moment so I've been unable to investigate. Any
other tools anyone woudl recommend?

Thanks

Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top