More practice with MVC-LH, reverse-engineering/tdd, & story-focues development.
A user can ...
- add two numbers & see result
- subract two numbers & see result
- chain operations (ie. use last result instead of 2 args)
- general purpose controller method
- multiply two numbers & see result
- divide two numbers & see result
- provide an expected value and see if they were right
- see a history of all operations
- clear the history of all operations
- reset last_result
story | UI | handler | controller | model | logic | view |
---|---|---|---|---|---|---|
1: + | two inputs, add button, output area | call_add: reads, cleans & passes on inputs | add: passes two numbers through logic.add & calls view | add: adds two numbers & returns the result | render: draws result to the UI | |
2: - | subtract button | call_subtract: reads, cleans & passes on inputs | subtract: passes two numbers through logic.subtract & calls view | subtract: subtracts two numbers & returns the result | ||
3: chain | refactor call_add & call_subtract to read from model when needed, and write new result to model | set_last_result, read_last_result | ||||
4: generalize | both buttons call the new generalized handler method | operate: reads operation, a, b. calls controller | operate: args - operation(str), a(num), b(num). uses indicated operation & reads/writes last_result | |||
5: * | mulitply button | multiply: multiplies 2 numbers and returns result | ||||
6: / | divide button | divide: divides 2 numbers and returns result | ||||
7: expected values | expected input field, test_it check-box, results output field | test: reads input, operation & expected value. passes on to controller | test: caries out the indicated operation, then compares the result & expected. calls view.render & view.render_test | test: takes args, exected & actual, returns pass/fail message | render_test: draws pass/fail message in test space | |
8: history of operations | button to read history, space to display it | read_history: calls controller | read_history: reads history and passes to view. refactor operate to save each call to the model as a string | add_call, read_all_calls | render_history: renders an array of strings to the history space | |
9: clear history | "clear call history" button | clear_call_history: calls controller | clear_call_history: clears the model's call history | clear_call_history | ||
10: set last_result | a "set last_result" input field & button | set_last_result: calls the model | set_last_result: resets it to the new value |