Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ntier application help

Status
Not open for further replies.

jennyflower

Programmer
Oct 10, 2006
60
GB
Hi,

I am currently trying to create a simple n-tier application so I can learn the basics of n-tier design and was wondering if someone could look at what I have so far to see if I cam on the right track for an n-tier application to work correctly. I am trying to have a presentation layer, a business logic layer, a provider independant data access layer and the database itself. I am pretty new to vb.net so I apologise if I get any of the terms wrong.

The example I have tried to create is a simple address book, and at the moment have created the bit that inserts titles (like Mr. Mrs. etc) into the database and also brings them out of the database into a combobox.

Right, so on my form (presentation layer) I have a text box, button and combobox. The user will enter a title in the text box, press the button which will add the title to the database then refresh the combobox with all the current titles from the database.

So when the user presses the Add Title button it call a function in the titleBusinessLogic class called CheckTitle()
This checks that there is something in the text box (carries out the business logic) then it calls a function in the DataAccessLayer class called Connect().

This will call another function in a class called Provider Factory, which sends back the correct connection object as a generic IDbconnection object. This is sent back to the data access layer and the connection opened.

Then the Title BusinessLogic class does the same thing for a command object, goes to the dataAccessLayer which goes to the provider Factory class, which sends back a command object as a generic command object.

Once this is done, there is a separate class which deals with the title database stuff called TitleFunctions. here is where i am going to put functions such as addTitle, GetAlltitles, GetOneTitle, DeleteTitle etc.


After looking online at loads of stuff about n-tier design I have tried to separate out the data access layer as much as possible so it is easier to maintain and update at later stages.

Does this setup seem like a good way to create an n-tier application for vb.net?
 
When designing this n-tier stuff you must think layered. I mean for example can you change the view without changing the BLL? can you change the DAL without changing the BLL.

Of course all this depends on how much loose coupling you want, because in the end there will always be some coupling. You can't just add a field in the database and magically want it to appear in the view.

Ask yourself this. Can my view/presentation work without the DAL? Can I put each layer on a different computer/server without changing much code? BTW if your layer run on the same computer then you would call it n-layered if each layer resides on another computer then you would call it n-tiered.

What you have there is more or less what CSLA.Net has In other words the BLL/Model/Domain is pretty smart. So look up CSLA.Net it is free (last time I checked) If you like more separation then you need to go a different route.

If you want it very loosely coupled then Spring.Net is the way to go or another DI-framework (Dependency injection).



Christiaan Baes
Belgium

My Blog
"In a system where you can define a factor as part of a third factor, you need another layer to check the main layer in case the second layer is not the base unit." - jrbarnett
 
You sound like you're on the right track. It is really a huge field and you could debate each step of it for hours. n-Tier design really benefits from having a couple of coders tossing ideas at each other ;)

The Data Abstraction Layer will determine a lot of your work. There are a bunch of different ways to attack this. I haven't been entirely pleased with any of the off the shelf stuff I've used, so I've written my own. But it was a serious project to under take, it and wasn't the first time I've worked extensively on a DAL.

The Business Layer can be a lot of fun too. This is where you can get into a lot of threading work. Although, that is one of my favorite aspects of coding right now, so I may be a bit biased when I say it is fun :)

Here are some documents I wrote up while going through the n-tier debate at a job a few years ago:


Hope they help, and good luck!

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thanks, yeah it seemed like everyone had their own interpretation of n-tier design so I kind of tried to make my own interpretation of everyone elses.

Thanks for the links!
 
The concept of n-tier is pretty standard at this point. Multiple layers that abstract the presentation from function and the data. The part that gets so heavily argued is how many layers to use (thus the 'n'), how tight/loose the coupling should be, what the limits for each layer are, and what functionality should be put into each layer.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top