metaprogramming. The accompany-
ing table shows critical topics from the
SWEBOK (software engineering body
of knowledge),
5 the Agile technique for
that topic, and the Rails tool that imple-
ments that technique. Because these
tools are lightweight, seamlessly inte-
grated with Rails, and require virtually
no installation or configuration—some
are delivered as SaaS—students quickly
begin learning important techniques
directly by doing them. We agree with
Confucius: “I hear and I forget. I see and
I remember. I do and I understand.”
Students see and use tools that we can
explain and check, rather than just hear
figure 1. An example feature for a cash register application and one “happy path” user
story for that feature.
Feature: Division
In order to avoid silly mistakes
Cashiers must be able to calculate a fraction
Scenario: Regular numbers
Given I have entered 3 into the calculator
And I have entered 2 into the calculator
When I press divide
Then the result should be 1. 5 on the screen
figure 2. the key section of the Cucumber and Ruby code that automates the acceptance
test for the user story in figure 1 by matching regular expressions.
Given /I have entered (\d+) into the calculator/ do |n|
@calc.push n.to_i
end
When /I press (\w+)/ do |op|
@result = calc.send op
end
Then /the result should be (.*) on the screen/ do |result|
result.should == result.to_f
end
figure 3. one Agile iteration in our course.
Talk to Customer
Legacy
Design patterns
Behavior-Driven Design (user stories)
Test-Driven Development (unit test)
Measure velocity
lectures about a methodology and then
forget to use them in their projects.
For example, the Cucumber tool
automates turning customer-under-standable user stories into acceptance
tests. Figure 1 is an example feature
for a cash register application and
one “happy path” user story (called a
scenario in Cucumber) for that feature (see http://en.wikipedia.org/
Such tools not only make it easy
for students to do what they hear in
lecture, but also simplify grading of
student effort from a time-intensive
subjective evaluation by reading code
to a low-effort objective evaluation by
measuring it. SimpleCov measures
test coverage, saikuro measures cyc-lomatic complexity of the code, flog
measures code assignment-branch-condition complexity, reek comments
on code quality by highlighting “code
smells,”f Cucumber shows the number of user stories completed, and Pivotal Tracker records weekly progress
and can point out problems in balance
of effort by members of teams. Indeed,
these tools make it plausible for the
online course to have automatically
gradable assignments with some teeth
in them.
Compared to Java and its frameworks, Rails programmers have found
factors of three to five reductions in
number of lines of code, which is one
indication of productivity.
6, 8 Rails also
helps with a criticism of Agile in that
TDD and rapid iteration can lead to
poor software architecture. We do teach
design patterns (see Figure 3). Indeed,
the Rails framework follows the Model
View Controller (MVC)g design pattern
f Code smells highlight to sections of code that
may be hard to read, maintain, or evolve.
g MVC is a design pattern that separates input
logic, business logic, and user interface logic
yet provides a loose coupling between them.