pdf见:http://obiefernandez.com/presentations/obie_fernandez-agile_dsl_development_in_ruby.pdf

1. What is DSL

——designed for a specific domain

——captures jargon in executable form

——can be internal or external

2. How to design Ruby DSL (1)

——Don’t try to do an abstract metamodel first (不要一开始就尝试建立抽象的元模型,元模型即模型的模型)

——Capture your DSL concepts in valid Ruby syntax, but don’t worry about implementation(用正确的Ruby语法来标识你的DSL概念,但不需要担心实现)

——Iterate over your Ruby DSL syntax until authors agree that it faithfully represents the domain, then work on the implementation(迭代改进你的Ruby DSL语法,直到业务专家认为语法足够真实代表这个领域,然后再考虑实现)

3.

Let the DSL you devise guide your implementation

——Kind of like TDD, don’t do more than what you need to make your DSL execute correctly

(让你设计的DSL引导你的实现。某种程度上就像TDD,不要做比你需要的更多的事情来让你的DSL正确运行)

DSLs that reflect business documents such as contracts are great

——Designing a DSL that’s as close as possible to the document it reflects makes verification of the system much easier!

(反应商业文档比如合同的DSL是最理想的。设计一种尽可能与领域文档接近的语言可以让系统的证明更为容易)

4. How to design Ruby DSL (2) —— Agile DSL Development

——Start with short iterations over the design(一开始,针对设计做短周期的迭代)

——Incorporate end-user feedback, pair with them if possible(吸取终端用户的反馈,如果可能的话与他们结对)

——Do TDD your context cod(利用TDD来写代码)

——Do refactor your context code often, but avoid over-engineering it(经常重构你的代码,但不要过度)

5. DSL的一些语法技巧

——Optional parentheses(可选的括号)

——Symbol(符号)

——Block(块)

——Literal arrays and hashes

——Variable-length argument(可变长的参数)

6. “the trick to writing DSL’s in Ruby is really knowing what you can and can’t do with Ruby’s metaprogramming features —— Jamis Buck, 37signals

(用Ruby编写DSL的技巧在于真正了解使用Ruby的元编程特征你可以做什么,不可以做什么)

7. Different types of Ruby DSL designs

(1) Instantiation——Your DSL is simply methods on an object

其实这种DSL就是方法调用,只不过方法的参数更加灵活,利用了Ruby的一些tricks

(2) Class Macros——DSL as methods on some ancestor class, and subclasses can then use those methods to tweak the behavior of themselves and their subclasses

这个可以参见我以前写过的关于Programming Ruby中Metaprogramming的章节,Marcos就是指通过这种方式可以将某些简短的名次扩展成更大的东西。

(3) Top-Level Methods——Your application defines the DSL as top-level methods, and then invokes load with the path to your DSL script.When those methods are called in the configuration file, they  modify some central (typically global) data, which your application uses to determine how it should execute.

你直接在脚本里定义方法,这个方法就会被注册到Object类中,因为你调用脚本的是Object类的上下文,所以这些方法在任何调用的脚本中都可用。

(4) Sandboxing——Your DSL is defined as methods of some object, but that object is really just a “sandbox”. Interacting with the object’s methods modify some state in the sandbox, which is then queried by the application

8. Ruby Features used by DSL implementors

• Symbols, less noisy than strings

• Blocks, enabling delayed evaluation of code

• Modules, for cleaner separation of code

• Splats, for handling parameter arrays

• eval, instance_eval, and class_eval

• define_method and alias_method

9. It’s a different way of thinking about writing code, and as such needs to be learned by doing, not by reading. Experimentation is the key!

Agile DSL Development in Ruby 笔记相关推荐

  1. 关于敏捷开发方法(Agile Software Development)的阅读笔记

    对"敏捷开发"(Agile Software Development)这个词,我是在这学期邹欣老师<现代程序设计>课上第一次听到的,刚听到时并不知道其具体指什么,只是从 ...

  2. 敏捷软件开发(Agile Software Development)简介之:什么是敏捷软件开发?

    http://www.ruby-lang.org.cn/read--tid-604.html 敏捷软件开发(Agile Software Development)简介之:什么是敏捷软件开发? 本文部分 ...

  3. 《3D Math Primer for Graphics and Game Development》读书笔记1

    <3D Math Primer for Graphics and Game Development>读书笔记1 本文是<3D Math Primer for Graphics and ...

  4. Chrome development tools学习笔记(3)

    (上次DOM的部分做了些补充,欢迎查看Chrome development tools学习笔记(2)) 利用DevTools Elements工具来调试页面样式 CSS(Cascading Style ...

  5. Book Excerpt: Succeeding with Agile: Software Development Using Scrum

    Scrum team members are used to seeing two new roles on their projects-the ScrumMaster and the produc ...

  6. [转] Agile Software Development 敏捷软件开发

    原文作者:kkun 原文地址:http://www.cnblogs.com/kkun/archive/2011/07/06/agile_software_development.html 敏捷是什么 ...

  7. ruby笔记 基于对象的类(object specific class)

    此笔记是为了帮助理解 "<<" 指令 ruby语言允许我们在一个对象的基础上定义类,使得我们可以单独扩展一个对象的行为,例子如下 test="hello&qu ...

  8. 敏捷软件开发宣言ndash;Manifesto for Agile Software Development

    敏捷开发, 谁不会呀, 不就是 没文档, 出活快, 用户说啥都能改? 下面是一个笑话,  王屋村的大牛说 - 我最近转手接了一个活, 完事能挣四五万, 我拿过图纸一看, 不就是盖一烟囱吗? 我们是敏捷 ...

  9. 敏捷软件开发宣言–Manifesto for Agile Software Development

    敏捷开发, 谁不会呀, 不就是 没文档, 出活快, 用户说啥都能改? 下面是一个笑话,  王屋村的大牛说 - 我最近转手接了一个活, 完事能挣四五万, 我拿过图纸一看, 不就是盖一烟囱吗? 我们是敏捷 ...

最新文章

  1. 配置MOSS的FBA步骤与问题(发现设置权限策略的里选人不好用,选不到Provider的人)...
  2. [IE]微软发布IE9预览版- 建议Web开发者开始研究SVG
  3. 获取redis实例绑定cpu的情况
  4. 前端学习(2237):react实现疫情数据
  5. 来,我们谈谈怎么学好计算机科学与技术
  6. 吴恩达机器学习笔记十四之大规模机器学习
  7. World Wind Java开发之四——搭建本地WMS服务器(转)
  8. 大数据_Flink_流式处理_简介_Flink的特点---Flink工作笔记0006
  9. oracle—“操作记录已被里一个用户锁住” 解决办法
  10. 3dmax shift用来复制对象
  11. @Slf4j注解的使用
  12. ACdream 1728 SJY's First Task
  13. python数独游戏源代码_Python数独游戏源代码
  14. kiss原则包括什么_KISS原则
  15. MySQL闪退以及服务中没有MySQL和MySQL 服务无法启动。系统出错。发生系统错误 1067。 进程意外终止。
  16. 博饼游戏c语言,2015中秋博饼游戏规则
  17. flutter图片切换闪一下
  18. 计算机导论第七章数据库基础,计算机导论教学大纲
  19. 《持续集成实践指南》第1章 DevOps实践简介
  20. 若依框架图片上传、富文本框编辑器功能

热门文章

  1. java实现计分_非常实用的java自动答题计时计分器
  2. mysql 集群操作系统_高性能MySQL集群详解(二)
  3. Udacity机器人软件工程师课程笔记(五)-样本搜索和找回-基于漫游者号模拟器-自主驾驶
  4. 【禅模式】如何进入极度专注的心流状态,让前端开发能力发挥到最大?设置VSCode禅模式快捷键Alt+F切换全屏,适合演示代码使用
  5. WebStorm中不小心勾选了不再显示更新项目的提示弹窗,如何重新显示版本控制(VCS)的更新项目Update Project(同步项目)提示弹窗?
  6. Django Python:完整的BUNDLE + Django真实项目2021
  7. ZBrush全面入门学习教程 Schoolism – Introduction to ZBrush
  8. 【73套】Epic Stock Media配乐音效素材合集包
  9. # Qt程序版本号使用
  10. 1 项目里面如何打印log日志