473,394 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

N-tier application : Suggestion for folder structure

Hi, my name is Nat Im a junior programmer, and Im trying to code a N-tier winform project in C#. I get the whole tier aka layer stuff fine, my question is: How do you do it? Folders? class libraries (.DLL) for the Business Logic? class objects? Data Sets for the Data Access Layer? HELP If someone can show me a basic folder/organization structure for the project ifself it would really help! Thanx
Nov 26 '07 #1
2 2477
KBTibbs
13
How do you do it? Folders? class libraries (.DLL) for the Business Logic? class objects? Data Sets for the Data Access Layer? HELP If someone can show me a basic folder/organization structure for the project ifself it would really help! Thanx
Folders can help, but they aren't necessary to divide your design into it's logical layers. Usually classes and interfaces (if you want to be able to replace sections of your code) are sufficient.

An example: I have a website that has members that log in. They can access the site, change personal information, etc (all the usual website things).

This can break up into three easy layers: UI (the web pages), the business logic (actions available to the user at the web page) and data access (database access for logins and anything else).

Each layer gets one of more classes, depending on how logical it is to combine functions. I'll go through Logging in as an example of how this could be handled.

UI Layer
User accesses the website and is presented with a login page that takes a username and password (could be more, like a security question, domain, etc.).
The user fills these in and clicks "submit." This calls a function from the class holding the business logic. We'll say it's
Expand|Select|Wrap|Line Numbers
  1. WhateverClass.Authenticate(string userName, string password)
The Business Logic layer
In
Expand|Select|Wrap|Line Numbers
  1. Authenticate(string userName, string password)
several things should happen based on the rules specific to the business. This code needs to see if the login is expired, and the user needs to change passwords. This code checks to see if the password is correct, if the user exists, etc. BUT it does this without ever directly touching the database. Instead, it passes it's needs to...

The Data Access Layer
This code is passed information, and returns information. Little to no changing of data occurs here (that usually happens at the BL layer). There can be legitimate reasons for manipulating data at this layer, but it's usually considered to be bending the rules. To go along with the logging in example, a method in this code could be to retrieve the stored password and salt (if hashed or encrypted) based on username. This method looks in the database and hands the result back up to the logic layer. It doesn't look at the data, it doesn't check to see if the input password is correct, it doesn't care. The logic layer asked it for information, and it handed it back. That's all this layer does (well, and it's handed data and it writes it to the DB too).

It's a fairly simplistic example, but hopefully it shows how you can logically break up your program into the n-tier design style. It all basically boils down into the following rules:

1) Your user interface shouldn't make decisions, it should be told what the decision is, and react accordingly (it's told the user logged in, or didn't log in).

2) The business logic layer shouldn't know what your UI is doing with the information it provides (all it know is that the UI wanted to know if the user logged in or not). The business logic layer also shouldn't know how the data acess layer does anything. It could be a file, it could be a database, it could be my Aunt Mildred writing on a notepad for all it knows or cares.

3) The data access layer doesn't think. It reads, writes and erases. Someone asks it for a user, it passes it up. Someone asks it to save something, it writes it down. That's what it does. It's told to erase something. Yes, sir. Right away sir.
Nov 26 '07 #2
Shashi Sadasivan
1,435 Expert 1GB
I make folders according to funtionality

they would contain the windows forms, classes, and Datasets (defining 3 layers)

the Ui should generally be free of any manipulation which can be classified as business logic (some time you cannot seperate it completely from the UI, like in a tranportation company, ice cream can only be transported in a freezer truck, and you are able to choose which product to ship in what)

This generally seggregates the modules

If you want you could store all UI Forms in one directory, classes in another, and datasets in another ( I have seen this too)
and create a similar directory structure within each of these.

So if you are looking for a class, you wud know that it would be in the business folder, and so forth. This will also be helpful to create DLL's easily if you need to. (so that there wont be the namespace Hell)
Nov 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ragha | last post by:
Dear friends I am emulating thr tree structure mentioned in the article http://www.15seconds.com/issue/010921.htm I have succesfully created the folder structure for level 2 I need this...
2
by: Tim Failes | last post by:
Our application needs to write some application specific data, but I have not been able to find the recommended method to obtain the correct pathname. I have found many references to the...
0
by: David Waddell | last post by:
Hi, I'm trying to setup a project folder structure in vs.net 2003 as follows : <project root> src doc test bin The only glitch I'm hitting is that the "New Class" wizard will append ".src"...
0
by: riversmithco | last post by:
Hi all, I am pulling my hair out on this one. I am following the Microsoft guidelines on how to structure folders and check in ASP.Net apps to VSS. Here's the problem: 1. I create a blank...
9
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3)...
0
by: andoband | last post by:
Using VS 2005, I have created a solution and it's projects using the following physical folder structure: d:\projects\Enterprise.root\Enterprise\Enterprise.sln...
1
by: rkoduru | last post by:
Hi All, I am looking for a script which will parse the folder structure (recursive) of a drive using my windows credentials (2003 domain) and give me the list of any folders/files that i dont have...
0
by: HarXon | last post by:
Hi, I am relatively new to C# and am attempting to implement the following: I currently have a text file containing the full path of all folders on a disk, from this i would like to create a...
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
0
by: Chuck Anderson | last post by:
I'm trying to come with a good organization plan for the Apache, Php, MySQL development software on my home PC and am wondering what sort of folder structure others may have come up with that seems...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.