Sharpening your APL knife
Design Issues
Don't repeat yourelf: DRY (1)
- Duplication increases the difficulty of change
- Duplication often decreases clarity
- Duplication leads to opportunities for inconsistency
- Therefore, code should not be duplicated
Don't repeat yourelf: DRY (2)
When the DRY principle is applied successfully...
- a modification of any single element of a system should not change other logically-unrelated elements
- logically related elements all change predictably and uniformly, and are thus kept in sync
Broken Windows (1)

- A car situated untouched in a street might be save for weeks
- As soon as a single window is broken...
- ...the car is likely to get destroyed within days...
- ...sometimes within hours!
Broken Windows (2)
- A "broken window" in an application that needs to be fixed asap
- If this principle is violated, others will start to care less as well
- No time/money to fix it right now?
- At least mark it as an area that surely needs refactoring
Defensive Programming -1-
- :Select something
- :Case 'OK'
- ...
- :Case 'CANCEL'
- ...
- :Else
- . ⍝ Huuuh?!
- :EndSelect
Defensive Programming -2-
- :If condition
- ...
- :Else
- . ⍝ Huuuh?!
- :EndSelect
Defensive Programming -3-
If there is any doubt about the quality of arguments which are essential:
- insert ⎕SIGNAL with appropriate checks...
- ... or equivalent cover functions
Diamond -1-
- Diamonds might be the girls best friends...
- ... but they are also programmers bad eggs
:If cond ⋄ statement ⋄ :EndIf
- This is ridicolous!
- In the Tracer, one cannot see what goes on!
Diamond -2-
mat←make 1 2 3 ⋄ mat←Process mat ⋄ mat←1↓[1]mat
- Again: In the Tracer one cannot see what goes on
- Harder to read anyway, without any advantage
- General rule: Don't use diamonds if there is not a very good reason!
Diamond -3-
Somethimes diamonds can be useful:
- ⎕TRAP←(11 'E' 'Statement1 ⋄ Statement2')
- ⎕LX←'Init ⋄ Appl.Run ⋄ ⎕←Info'
- Build a string to be executed with ⍎
- In dyamic functions
End