zoukankan      html  css  js  c++  java
  • 典型的分层、接口和工厂的写法

    微软宠物店的分析

    ---------页面表现层Web----------------------
    Product product = new Product();
    IList productsByCategory = product.GetProductsByCategory

    ((string)ViewState[KEY_CATEGORY]);


    ----------商业逻辑层---------------------
    namespace PetShop.BLL
    public class Product {
    IProduct dal = PetShop.DALFactory.Product.Create();  
    return dal.GetProductsBySearch(keywords);
    }


    ---------接口层--------------------------
    namespace PetShop.IDAL{
    public interface IProduct{
      IList GetProductsByCategory(string category); 
      }
    }


    ------------数据访问层--------------------
    public class Product : IProduct{
    public IList GetProductsByCategory(string category) {
    ......}
    }

    ----------静态工厂方法--------------------
    namespace PetShop.DALFactory {
    public class Product {
    public static PetShop.IDAL.IProduct Create() {
    string path =

    System.Configuration.ConfigurationSettings.AppSettings

    ["WebDAL"];
    string className = path + ".Product";
    return (PetShop.IDAL.IProduct)Assembly.Load

    (path).CreateInstance(className);
      }
     }
    }

  • 相关阅读:
    onclick中的函数的参数this
    classList的使用
    设置点击鼠标时不跳转
    模块补充shutil,logging
    re模块拾遗和递归函数
    正则表达式-re模块
    软件开发规范
    自定义模块2
    常用模块
    初识自定义模块
  • 原文地址:https://www.cnblogs.com/babyblue/p/36125.html
Copyright © 2011-2022 走看看