OO BootCamp
consulting
what
首先,它是一个workshop,它主要是编程。
其次,它讲述的在敏捷开发中面向对象的编程技术与实践。
第三,它面向所有未接触过敏捷开发的人员,包括有经验的传统开发者。
第四,它采用结对编程和测试驱动的方式进行,所以OO训练营也讲测试驱动开发,当然包括重构。
第五,其他敏捷开发实践和原则,比如简单设计。
简单总结一下,OO训练营是用实践写代码的方式学习与体验我们公司关于敏捷开发中面向对象的编程技术以及开发实践。基于以上原则,那么OO训练营不会讨论关于语言的细节问题,不讨论算法,Git等其他无关的东西。
how
- 上一轮OO训练营代码展示和点评(如果上次有家庭作业)
- 顾问提出需求
- 分组讨论和UML设计(如果需求简单,则跳过此环节)
- 结对开发
- 代码演示
- 点评和顾问总结
- 布置家庭作业
内容
简单设计四原则
- It works
- At the most basic level the code must do what it is supposed to do. green bar - tests pass.
- It communicates
- You should be able to read the code directly. The code itself should express its intent. The best world is where the code reads like english. people have dozens of years of practice understanding english and the closer your code gets to english the easier will be to read. That is why we use full parameter names ('probability' instead of 'p') and we use method names that clearly express the intent of the method. If your code requires a lot comments then the code itself is not communicating. Seeing comments in your code likely points to an opportunity to improve the way the code communicates and then delete the comments.
- Short method names are prefered to long method names.
- Long method names often indicate the method is doing too much and could be broken into simpler methods. for example if your method name has an 'and' in it then it is probably doing too much
- Code should be easily understandable. if there are too many words it becomes harder to read and understand.
- No duplicate code
- Duplicate code creates barriers to maintanence and leads to the strong possibility of eventual contradiction. to work with duplicated code you have to know that it is duplicated and make modifications in all locations
- DRY (don't repeat yourself)
- No extra code
- Cost of ongoing maintanence
- Having the extra code may inhibit good factoring of your code and hide valuable abstractions
- You can't predict the future: your understanding of the system/design changes, requirements change, etc
- YAGNI (you ain't gonna need it)
appendix