Application Architecture

Application Structure Best Practices

A very important thing to setup immediately from the start is a solid application project structure.

Typical Multi-Layer
Structure 1

  • Application.Core
  • Application.Data
  • Application.Service
  • Application.WebServices
  • Application.UI
  • Utilities
  • Utilities.Providers
  • Utilities.UnitTests
  • Appication.UnitTests
Modular ( Forums, Articles )
Structure 2

  • Application.Core
  • Application.Common
  • Application.Forums
  • Application.Articles
  • Application.CalendarEvents
  • Utilities
  • Utilities.Providers
  • Utilities.UnitTests
  • Application.UnitTests

Importance of application structure:

  1. Promotes unit-testable code if combined w/ unit-testing / TDD
  2. Promotes developing an easy API to your application.
  3. Clearly defines the boundaries / layers of your application
  4. Provides an organized view of your solution to get and place code

Typically, projects can be organized via 2 approaches.
Structure 1:
In the first approach, the projects are layered technically( User Interface, Data / Persistance, Service, WebServices, etc). This means that the different features/functionality (articles, forums, q & a) are split up across these technical layers. This is a common,  very simple and effective solution structure.

Structure 2:
In this approach, the projects are layers functionally / feature wise. Each project represents a specific feature and the technical layers ( User Inferface, Data / Persistance, Service ) exists for each feature and are organized within the project. This makes the overall application much more “pluggable” and modular as a whole.

Described below are some of the typical components in each layer.

Application.Core

1. Domain / Business objects
2. Constants common to all layers
3. Common utility components shared by multiple layers
4. Interfaces for your data access / service / web services components
5. Some core validation components for your business objects

Application.Data

Your data access / persistence layer.
1. GenericDao implementation
2. Custom Dao’s / Repositories

Application.Service

Also referred to as your Application Layer.
This is the layer that your application GUI really interacts with. This may consist of components that augment your business logic with
1. Security
2. Notifications
3. Further validation
4. Delegating calls to your Persistence components ( e.g. Dao’s )
( If your business objects are not built as Active Records )

Application.UI

Your presentation layer that your core application GUI can interact with.
Components that belong here:
1. View interfaces.
2. Presenters
3. Controllers ( Note: Controllers can serve same function as Services )
4. Common User Interface layer code.

Application.WebService

Your “web services” layer. Web services can itself represent a range of options.
For example:
1. An Xml REST API.
2. Ajax server request handlers ( similar to #1 )
3. SOAP based web services.

Application.Forums

In this project ( representing structure 2 above ), you have all the code/technical layers representing your Forums functionality in a single project.
1. Data Access / Persistance code
2. Services for forums related functionality.
3. Presentation code for forums.

Utilities

Utility / Helper components that are not specific for your application.
This code could potentially be ported to another application if needed.
This should NOT have any references to Third Party Components
1. Helper classes
2. ICache interfaces

Utilities.Providers

Utility components that implement interfaces present in Utilities.
These are implemented using a Provider Model design pattern.
1. ICache implementations ( e.g. wrap Spring AspNetCache )

Utilities.UnitTests

This projects contains all your unittests for your utility code.

Application.UnitTests

This project contains all your unittests for you application level code.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: