How does a 3-tier architecture work?
What goes where?
I got these questions last week, at the start of
a new project.
Here are the answers, a personal point of view:
The 3 layers
The GUI is the "top layer".
It contains all things that are visible to the user, the 'outside' of the system, such as screen layout and navigation.
The GUI layer has techniques like HTML, CSS, Applet, Servlet, JSP, JHTML.
This is the core of the system, the linking pin between the other layers.
The object layer has knowledge, in two different ways:
In the object layer you'll find things like Classes, objects, instance variables, vectors, primitives, methods,
The objects mostly have a temporary nature.
They "live" just in memory for the duration of a transaction or session.
The database layer takes care of persistency.
An object from the object layer can write itself to one or more tables.
In the database layer you'll find things like database, connection, table, SQL and result set.
- runtime values, like the customer name "Oxford & Associates" or the invoice number "OAA2000w36".
- Structural knowledge, about data and processing.
- Data example
- A customer can receive many invoices, and an invoice always goes to just one customer.
- Proces example
- Know who does what.
Every objects knows his own methods, and those of his neighbours.
In a pure OO model an object talks to his neighbours, and nobody but his neighbours.
Till next week!
the right approach
the 3-tier architecture saves development manpower.
Code each bit only once, with powerful reusage.
- Divide and conquer strategy.
Every layer is rather easy to develop.
Better have 3 simple parts that one complex whole.
For each layer a specialist can contribute specific expertise,
for the user interface,
for the object layer,
for the tables.