views:

511

answers:

5

How do you guys organise your asp.net web applications? Do you have you classes in the applicaiton, or in a seperate class library? How do you split your classes into name spaces, by type, function, tier? I've got a great working applicaiton, but the codes a bit messsy, I want to look at the best way to organise it.

+1  A: 

I keep it simple.

App_code - contains classes which are grouped into folders

Controls - contains user controls grouped into folders

images - contains images

styles - contains css

js- contains javascript

Folders for any additional grouping of pages where it makes sense. example: Admin pages go into admin folder. The admin master page would go in this folder as well.

Brian Bolton
+3  A: 

I organize my classes by layers.

In small projects I have a Class Library for Data Access, a class library for business entities, a class library for Utility Classes including my reusable code, and a Web Application Project.

Namespaces are like this :

  • MyProjectName.DAL
  • MyProjectName.BLL
  • MyProjectName.Utility
  • MyProjectName.Web

I never add classes into web application project.

Canavar
Why would you never add classes into a web project?
Brian Bolton
If I decide it is a class the it must have a place in my library, must be in a class library. My web application is only for web files. To find it quickly maybe :)
Canavar
When you say class library, are you talking about a separate assembly that contains your classes?
Brian Bolton
A: 

I'm with ScarletGarden on this one. My preference is to create separate class libraries for the logical components and keep classes out of the web app wherever possible. If you need to reuse the libraries, port the functionality to a different technology (desktop, mobile, etc), or write unit tests against your logic, it really comes in handy to have them as stand alone units.

Rich
A: 

core components, library components, module components, templates, and configuration/environment/bootstrap

/includes

/core
/lib
/modules
/templates
config
enviornment

is the basis of my app structure, the actual application has a single point of entry so pretty much everything is controlled from this or sub-directories off of it.

Syntax
A: 

I usually use a combination of what Brian and ScarletGarden said. I like to have my business logic and data access in a separate class library, but web-related utility classes, page base classes, etc. go in folders in the web project. If I think my custom controls will be reused I'll give them a separate project too.

CodeMonkey1