在開發web-based應用系統時,必須對資料庫作存取。但在一大型 web-based應用系統中,這些存取資料庫的程式會有許多重複出現的狀況。如為了提可再使用性及系統的可維護性,因此有必要將系統的資料庫存取程式和商業邏輯程式作分離。 我們使用Data Access Object (DAO)這種模式,然後配合Spring Framework的IoC/DI的概念,動態注入物件間的關係,提升DAO程式的可再使用性。我們以一個實際軟體專案為範例,經重整後,當資料庫存取改變而需修改許多Web程式內的相同SQL語法時,我們只需修改一個地方,這樣系統日後易於維護。
We must access the database when developing a web-based application system. But in a large-scale web-based application system, the programs for database access are usually duplicated. In order to enhance the reusability and maintainability of a system, it is necessary to separate the database access from business logic. The data access object (DAO) pattern was used for this purpose. This pattern was then adapted to the Spring framework, which is an IoC/DI framework that dynamically injects the relationship among objects. This will enhance the reusability of DAO programs. A real software project was used as an example. After refactoring, we only need to change one SQL statement programs when same pattern of database access is changed. The system is thus easier to maintain.
為了持續優化網站功能與使用者體驗,本網站將Cookies分析技術用於網站營運、分析和個人化服務之目的。
若您繼續瀏覽本網站,即表示您同意本網站使用Cookies。