【发布时间】:2011-11-27 14:19:59
【问题描述】:
假设 ruby 中的应用程序启动时有两种模式:命令行模式和文件模式
当给定参数ruby myprogram input.txt output.txt时,它会根据输入文件中的一些命令生成输出。同样,当没有提供任何参数时,它会为我们提供命令提示符。使用以下命令。
create_class_with_capacity 40
create_student_with_marks Alex 70
create_student_with_marks Mathew 30
create_student_with_marks John 55
..
create_student_with_marks Sylvia 70 etc...
fail_student_roll_no 12
=> Student with roll number 12 #{student} failed
give_marks_to_roll_no 70 1
=>Student with roll number 1 Alex got 70 marks
find_all_students_with_marks 70
=> Alex, Peter , Russell , Mark etc...
如何设计这样的应用程序,同时牢记 RSpec、TDD、Cucumber、SOLID 和模式。 我直接问的是这里的对象应该是什么来设计什么应该是模块(如果适用)等等。?以及如何衡量这里需要测试的内容和不需要测试的内容?在面向对象设计方面设计最合适的机制。
还请参阅一些书籍或博客以了解这些面向对象的 ruby 设计原则和实践。
【问题讨论】:
标签: ruby design-patterns rspec cucumber solid-principles