Eigenpoll : Best Practices for Software Development : Layering 

Use an Layered software Architecture

Something like

1) Interface Layer
This is the applications interface to the outside world
it could handle input from a gui or a data stream.

2) Application Layer

Here you put all the application specific code.
Sometime called the model layer.

3) Domain Layer
Here you put domain specific and application independent code.

sometime called the business rules layer.

4) Technical Layer
Typical math, XML and other standard libraries.

5) Platform Layer
This is the Platform specific code like Databases, communication
and OS specific functions.

An layer should only depend on layers below it self
and ideally only on the layer just below it self.