Petshop3.0學(xué)習(xí)筆記(四)應(yīng)用程序接口層在面向?qū)ο蟮膽?yīng)用程序開發(fā)中,類的接口是一個(gè)很重要的概念,在.net框架中,.net不僅提供了強(qiáng)大的面向?qū)ο蟮奶匦?,而且它也給我們提供了一系列強(qiáng)大的接口供我們使用,好了我們就來看看petshop3.0中的接口層,從解決方案管理器中的PetShop.IDAL命名空間中,我們可以看到幾個(gè)接口:IAccount、IInventory、IItem、IOrder、IProduct、IProfile,我們以IAccount為例:
//References to PetShop specific libraries //PetShop busines entity library using PetShop.Model;
namespace PetShop.IDAL { /// <summary> /// Inteface for the Account DAL /// </summary> public interface IAccount { /// <summary> /// Authenticate a user /// </summary> /// <param name="userId">Unique identifier for a user</param> /// <param name="password">Password for the user</param> /// <returns>Details about the user who has just logged in</returns> AccountInfo SignIn(string userId, string password);
/// <summary> /// Get a user's address stored in the database /// </summary> /// <param name="userId">Unique identifier for a user</param> /// <returns>Address information</returns> AddressInfo GetAddress(string userId);
/// <summary> /// Insert an account into the database /// </summary> /// <param name="account">Account to insert</param> void Insert(AccountInfo account);
/// <summary> /// Update an account in the database /// </summary> /// <param name="Account">Account information to update</param> void Update(AccountInfo Account); } } 這個(gè)外露的接口,提供了一系列的操縱帳戶信息的相關(guān)功能的函數(shù),就像接口的定義那樣,我們不必了解這個(gè)接口具體是如何實(shí)現(xiàn)的,只要我們?cè)跇I(yè)務(wù)處理層能夠好好使用就行了,按我的理解接口是一系列功能的集合,他把應(yīng)用程序不同的層次劃分得很清楚,這樣我們?cè)谛薷牡讓拥臄?shù)據(jù)庫處理過程實(shí)現(xiàn)的時(shí)候就能夠不修改業(yè)務(wù)處理層和表現(xiàn)層的代碼,這也是N層應(yīng)用程序系統(tǒng)架構(gòu)模式的好處,層次清晰,不同實(shí)現(xiàn)的分離,代碼的效率顯著提高了,他具有良好的封裝特性。 分類: PETSHOP3.0寵物商店
|
|