zoukankan      html  css  js  c++  java
  • 烹饪,简单工厂(Simple Factory)

    “烹”就是煮的意思,“饪”是指熟的意思,狭义地说,烹饪是对食物原料进行热加工,将生的食物原料加工成熟食品;广义地说烹饪是指对食物原料进行合理选择调配,加工治净,加热调味,使之成为色、香、味、形、质、养兼美的安全无害的、利于吸收、益人健康、强人体质的饭食菜品包括调味熟食,也包括调制生食。

    因此,我们产生一个烹饪类: 

    Cook
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    /// <summary>
    /// Summary description for Cook
    /// </summary>
    namespace Insus.NET
    {
        public class Cook
        {
            public virtual void CookedFood()
            { 
                
            }
        }
    }


    烹饪的方式有很多:

    油传热:炒,煎,贴,烹,炸,溜

    烹:卤汁不加淀粉勾芡,余同溜。

    生料炒,叫煸。

    炒后水传热:熬,烩,焖,烧,扒

    熬:先把料物炒一炒,然后加汤至熟。调味料可在加汤前或汤后加。

    烩:出锅前勾芡,余同熬。

    焖:亦作炆,先炒,然后加汤和调味品,微火,至熟。

    烧:加汤和调料后,微火至接近熟,再以旺火收汤。余同焖。

    扒:出锅前勾芡,余同烧。

    :将煎或炸过的原料加调料小火制熟的过程,如:大虾,鲫鱼等,具有口感酥烂,汁浓味美的特点。

    水传热:汆,涮

    煮:投料物于水(凉、温、开),加热至熟

    炖:旺火收汤。余同煮。

    煨:主要用于不易酥烂的料物,如脚爪一类。宽汤旺火。

    焐:温火久热。余同煨。

    汽传热:蒸,鲊

    其它:卤,酱,熏,烤,炝,腌,拌,拔丝

    焗:以盐为热介质的烹调方法,如盐焗鸡。成菜具有味醇厚,鲜香味美的特点。

    调料:自然粉

    接下来,我们产生炒,煎,煮,炖等类:

    烹饪“炒”类:

    Fry
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    /// <summary>
    /// Summary description for Fry
    /// </summary>
    namespace Insus.NET
    {
        public class Fry : Cook 
        {
            public Fry()
            {
                //
                // TODO: Add constructor logic here
                //
            }
    
            public override void CookedFood()
            {
                HttpContext.Current.Response.Write("炒方式的食物...");
            }
        }
    }


    烹饪“煎”类:

    PanFry
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    /// <summary>
    /// Summary description for PanFry
    /// </summary>
    namespace Insus.NET
    {
        public class PanFry : Cook 
        {
            public PanFry()
            {
                //
                // TODO: Add constructor logic here
                //
            }
    
            public override void CookedFood()
            {
                HttpContext.Current.Response.Write("煎方式的食物...");
            }
        }
    }


    烹饪“煮”类:

    Boil
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    /// <summary>
    /// Summary description for Boil
    /// </summary>
    namespace Insus.NET
    {
        public class Boil : Cook
        {
            public Boil()
            {
                //
                // TODO: Add constructor logic here
                //
            }
    
            public override void CookedFood()
            {
                HttpContext.Current.Response.Write("煮方式的食物...");
            }
        }
    }


    烹饪“炖”类:

    Stew
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    /// <summary>
    /// Summary description for Stew
    /// </summary>
    namespace Insus.NET
    {
        public class Stew : Cook
        {
            public Stew()
            {
                //
                // TODO: Add constructor logic here
                //
            }
    
            public override void CookedFood()
            {
                HttpContext.Current.Response.Write("炖方式的食物...");
            }
        }
    }

     
    简单烹饪工厂类:

    CookFactory
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    /// <summary>
    /// Summary description for CookFactory
    /// </summary>
    namespace Insus.NET
    {
        public class CookFactory
        {
            public static Cook CreateCook(string cookingMethod)
            { 
                Cook cook = null;
                switch (cookingMethod)
                { 
                    case "":
                        cook = new Fry();
                        break;
                    case "":
                        cook = new PanFry();
                        break;
                    case "":
                        cook = new Boil();
                        break;
                    case "":
                        cook = new Stew();
                        break;
                }
    
                return cook;
            }
        }
    }


    客户端aspx代码:

    SimpleFactoryDemo.aspx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Insus.NET;
    
    public partial class SimpleFactoryDemo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Cook cook;
            cook = CookFactory.CreateCook("");  //传入不同的烹饪方式
            cook.CookedFood(); //得到不同的烹饪食物。
        }
    }

     
    上面部分文字(字体颜色为靛青色)来自网络摘录。



    下面内容于2014-12-19 14:44分补充:

    最后一个简单烹饪工厂类(CookFactory),我们可以重构一下Switch方法。由于所switch的字符串与所new的类名完全不一样,因此没有办使用反射。但我们可以使用一个中介者设计模式来解决,创建一个中介者:



    然后就可以重构switch分流程序了:

  • 相关阅读:
    drf认证组件
    播放音频
    推荐
    makefile编写
    qt文件操作mv
    qt文件http网络下载
    为qt在window上用源代码编译库 (部分转载)
    qt线程池(转)
    crc校验
    树莓派网络配置查询
  • 原文地址:https://www.cnblogs.com/insus/p/2937873.html
Copyright © 2011-2022 走看看