enigma
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:
# The Butterfly flaps its wings
## Is TDD complex or simple?

[Steve Freeman](https://twitter.com/#!/sf105) and [Jamie
Dobson](https://twitter.com/#!/financialagile) ran this excellent session at
[SC2012](http://www.codemanship.co.uk/softwarecraftsmanship/).  They are running
it again at
[SPA2012](http://www.spaconference.org/spa2012/sessions/session413.html).

Each pair has to program an Enigma machine. They are given some detail on how it
works, and are given a paper machine with which they can generate some
acceptance test data.

By each pair working in their own chosen environment/language, and approaching
the problem in their own way, the hope is that some data around how starting
conditions affect the design of the code.

## Our attempt

I paired up with [Gavin Heavyside](https://twitter.com/#!/gavinheavyside) and
the code that we produced during the session is [here]().

We started off spending some time figuring out how the machine worked, and tried
to model that as a sequence diagram.

![Enigma Machine Sequence Diagram](https://github.com/tooky/enigma/raw/master/enigma-machine-sequence.png)

We then wrote some high level acceptance tests, based on the information that we
had been given. We checked encoding a single character, decoding a single
character, and checked that a renecoding a decoded message gave back the same
encoded message.

We wrote the acceptance test to give us an idea of the interface that we wanted,
something like:

```ruby
machine = Machine.new Rotor::I.at('M'), Rotor::II.at('C'), Rotor::III.at('K')
machine.call("AMSGFRCDNG")
```

As we were working we discovered that having an operator to deal with the
machine felt more natural. The operator would deal with splitting the message
into individual characters, and recombining the coded characters.

We also added a RotorMechanism, which allowed the machine to treat the rotors
as a black box.

## Result

We managed to get to the point that we were able to code and decode single
characters, we didn't quite get to moving the rotors so we couldn't decode
a message.

Its a great little exercise. If you want to try it your self download the [paper
enigma machine](http://mckoss.com/Crypto/Paper%20Enigma.pdf).

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。