深入理解Interpreter模式
来源:互联网 发布:樱井知香喷泉图片下载 编辑:程序博客网 时间:2024/06/05 00:44
1)Interpreter模式是一个能给人留下深刻印象的模式。
The Interpreter pattern describes how to define a grammar for simple languages, represent sentences in the language, and interpret these sentences.
GoF书中的这句话是点睛之笔。1)定义语法;2)组织句子;3)解释句子;
例如用户创建自定义查询:这里的查询就是解释器模式中的句子,与或非等逻辑是语法,而解释(eval方法)就是各个子类根据自身所做的分析。
2)造句:
Query current=new Query("Status", "Equals", "1") & new Query("ItemType", "Equals", "0");string result=current.eval();总结:它的精妙之处和Composite模式一样,Composite可以构建一个复杂的树形结构。而Interpreter模式也可以构建一个复杂的句子,这个句子实际上也是树形结构。
0 0
- 深入理解Interpreter模式
- Interpreter 模式
- interpreter模式
- Interpreter模式
- Interpreter模式
- Interpreter模式
- Interpreter模式
- Interpreter模式
- Interpreter模式
- 深入理解NAT模式
- 深入理解Iterator模式
- 深入理解Composite模式
- 设计模式深入学习--Interpreter 解释器模式(行为型模式)
- 深入理解浏览器兼容性模式
- 深入理解浏览器兼容性模式
- 深入理解浏览器兼容性模式
- 深入理解浏览器兼容性模式
- 深入理解浏览器兼容性模式
- 自定义带返回上层视图的导航栏控制器(配合自定义视图使用)
- gt9xx系列------实现实体按键的unpin解锁
- Action的重定向-Struts2中防止表单重复提交的两种方式(二)
- AVL树的插入与删除
- Android通过HttpURLConnection与HttpClient联网代理网关设置
- 深入理解Interpreter模式
- 谷歌又惹新麻烦 法国将对其网络广告展开调查
- WPF 多线程设计
- 如何在QML应用中创建类似ContextMenu的控件
- SpringMVC Controller写法
- AWS Ubuntu Lampp + wordpress install
- jQuery常用插件总结
- 升级 HTTPS,价值何在?
- SLF4J