View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Coweb Assignment Two


Improving the design of the code so that its cheaper and easier to maintain. The goal is to not only write code that computers can read, but also humans.

Two indications of refactoring are classes which have long methods and duplication of code.
To avoid long methods, a better design has to be implemented so that one method does not handle too much work and can distribute its work to other functions which are called from this one method.
Duplication can be avoided by good design as well. Duplicated code is caused by copying and pasting the same code. This code should be transferred to another method and this method should be called when required.

Unit testing is useful during refactoring since it ensures that broken code still works. Every time the code is refactored, major changes in design could be made and the code still has to work in order for the refactoring to be useful.

User Interfaces

The model of the real world should be seperated from the user interface view. The model and the view are going to change over time. The design should not be such that the model should be tweaked every time that the view is changed and vice-versa.
In order to function independent from each other, the model and view has to be able to function by themselves and that's how the MVC achieves the design.

Tracing Code:

1 + 2 * 3 – 4 factorial
Output: -15

a := #(1 2 3 4 5)
Output: #(1 2 3 4 5)

a select: [:i | i odd]
Output: #(1 3 5)

b := a
Output: #(1 2 3 4 5)

a := a reversed
Output: #(5 4 3 2 1)

b collect: [:i | i * i]
Output: #(1 4 9 16 25)

a perform: #at: withArguments: #(4)
Output: 2

Link to this Page