Creating n-tier solution

R

Robin

In a current .Net solution (using VB.Net) has a 3 tier architecture of Web
interface, Data Access Layer and Database.

How do I implement business logic and class layers into this solution?
 
M

Marc Castrechini

We simply added a business layer to that approach which carries the business
logic and classes.

Web GUI
Business Layer
Data Access Layer
Database
 
M

Marc Castrechini

Also, from what I understand the 3 Tier approach generalizes the division of
Presentation vs Application vs Data logic.

Can anyone confirm or correct this?
 
B

Bobby Ryzhy

Create a new Project - Other Projects - Enterprise Template Projects - C# or VB Building Blocks - Then Create a Presentation layer, Business
Rules or Facade and a Data Access layer. Have the Presentation reference the Business, and the Business reference the Data - and make sure
you are super vigilant in putting the right stuff in the right layer. After a while it will become second nature.

Bobby Ryzhy
bobby@ domain below
http://weekendtech.net

In a current .Net solution (using VB.Net) has a 3 tier architecture of Web
interface, Data Access Layer and Database.

How do I implement business logic and class layers into this solution?

Bobby Ryzhy
bobby @ domain below
http://weekendtech.net
 
K

Kevin Spencer

3-tier is a bit misleading. You can have as many tiers as you logically
need. For example, we have a 5-tier model, which has a business layer
between the Interface and Data Access layers, and our presentation layer is
divided into 2 layers as well - one for presentation logic/HTML, and CSS for
presentation layout.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
G

Guest

Attached you will find a zip file. This is the Teired solutions that I use.

We have several large client of ours using this model and it works great.

There are 4 files using Inhertiance which makes it simpler (for me at least)
to keep maintained.

Base.vb - is a must inherit class that basically contains all the fields in
the database and the types. With a function that set a default value in the
fields.

DataAccess.vb - is a must inherit class which inherits the Base class (to
get all the properties) but it can have it own property usually readonly
and the results of joins. This class allow for the updating, deleting, and
create of a single record in the in the database. This also contain
multiple record results in the form of a strongly type collection to reduce
processing overhead and bytes transmitted. Strongly typed collection can
still be bound to anything accepting a .DataSource. Also contain several
function to manage the cache (creation and expiration) of results and items
from the database

BusinessLogic.vb - Inherits the DataAccess class and contains the Validate
function to validate the updates and creates going into the database.

Collection.vb - Custom Strong Type Collection used in the DataAccess to
return results. Contains two classes ...Item and ...ItemCollection
(generated by CodeSmart)

At first this looks like a lot of code to create each time however I have
taken this style of code and using a templated based generation tool called
CodeSmith I created a custom template so I can generate about 90% all the
code I need in about 15 seconds. But some the advantanages are:

- all the data is cache reducing data hits
- all cache expires at 100 seconds (you can change this)
- all cached in managed force updated data out of cache only if it meets
certain criteria.
- business logic is only written one time.
- Everything is strongly typed allowing you to referece (set/get) fields the
Instance.FieldName
- Strongly type collection are by my testing faster, more flexable, and
smaller than Dataset.
- And with CodeSmith it can be generate very very quickly.

I am sure this answer is over kill for your question, but maybe you will
find something else you like in there too.

BTW. Once you do all the VB files you can just create an Reference to the
dll and then...

If you it a data collection you can reference it directly

Gizmo.DataSource = [Root Name Space].Role.GetAllRole()
Gizmo.DataBind

Or by an instance for create, drop, update.

' For create
Dim oRole as New [Root Name Space].Role()
oRole.Description = ""
oRole.Inactive = False
oRole.Create 'Returns a new unique identifier value if you want it


'For Edit key represent the unique row identifier. BTW, remember validation
of the field is done in the class no need for it here.
Dim oRole as New [Root Name Space].Role(Key)
oRole.Description = "Updated Role Description"
oRole.Update 'Returns true or false on the successful completion of process

'For Delete key represent the unique row identifier
Dim oRole as New [Root Name Space].Role(Key)
oRole.Delete 'Returns true or false on the successful completion of process



'Throws an error if business logic encounters an error
Try
Dim oRole as New [Root Name Space].Role(Key)
oRole.Description = "Updated Role Description"
oRole.Update ' or can be .Create or .Delete
Catch e As Exception
'Handle you error here any way you want.
End Try





'To get data out, single record, say a form, key represent the unique row
identifier
Dim oRole as New [Root Name Space].Role(Key)
txtDescription.Text = oRole.Description
cbxInactive.Check = oRole.Inactive



Somewhat straight forward.


-Wayne
 
R

Robin

Using following n-tier, database, DAL, class, business logic and Asp.Net,
how do you return class data/data set to the Asp.Net Layer to display all
the data?

As the class and DAL layers are not visible at the Asp.Net layer.
 

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

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,199
Latest member
AnyaFlynn6

Latest Threads

Top