分層模式的用途首先是將複雜的問題進行分解. 其次是允許複用Business logic以及conserve valuable connections to expensive resources such as databases。
Three Layered Application
Context
You are building a business solution using layers to organize your application.
Problem
How do you organize your application to reuse business logic, provide deployment flexibility and conserve valuable resource connection?
Solution
Create three layers:presentation, business logic(domain), and data access. Place all components responsible for the view in the presentation layer. Encapsulate all business logic in domain layer components that implement well-known component interfaces.Locate all database-related code, including database client access and utility components, in the data access layer. Require the data access layer to be responsible for connection pooling when accessing resources. Make sure you eliminate the dependencies between the business layer and the presentation layer or manage the dependencies here using the Observer pattern.