辣手藏家 下载:Petshop3.0学习笔记(四)应用程序接口层 - torome - 博客园
来源:百度文库 编辑:九乡新闻网 时间:2024/04/30 02:38:48
Petshop3.0学习笔记(四)应用程序接口层
在面向对象的应用程序开发中,类的接口是一个很重要的概念,在.net框架中,.net不仅提供了强大的面向对象的特性,而且它也给我们提供了一系列强大的接口供我们使用,好了我们就来看看petshop3.0中的接口层,从解决方案管理器中的PetShop.IDAL命名空间中,我们可以看到几个接口:IAccount、IInventory、IItem、IOrder、IProduct、IProfile,我们以IAccount为例:
using System;
//References to PetShop specific libraries
//PetShop busines entity library
using PetShop.Model;
namespace PetShop.IDAL
{
/// /// Inteface for the Account DAL ///
public interface IAccount
{
/// /// Authenticate a user ///
/// Unique identifier for a user
/// Password for the user
///
AccountInfo SignIn(string userId, string password);
/// /// Get a user's address stored in the database ///
/// Unique identifier for a user
///
AddressInfo GetAddress(string userId);
/// /// Insert an account into the database ///
/// Account to insert
void Insert(AccountInfo account);
/// /// Update an account in the database ///
/// Account information to update
void Update(AccountInfo Account);
}
}
这个外露的接口,提供了一系列的操纵帐户信息的相关功能的函数,就像接口的定义那样,我们不必了解这个接口具体是如何实现的,只要我们在业务处理层能够好好使用就行了,按我的理解接口是一系列功能的集合,他把应用程序不同的层次划分得很清楚,这样我们在修改底层的数据库处理过程实现的时候就能够不修改业务处理层和表现层的代码,这也是N层应用程序系统架构模式的好处,层次清晰,不同实现的分离,代码的效率显著提高了,他具有良好的封装特性。 分类: PETSHOP3.0宠物商店