Sharpening your APL knife

Design Issues

Don't repeat yourelf: DRY (1)

Don't repeat yourelf: DRY (2)

When the DRY principle is applied successfully...

Broken Windows (1)

Broken Windows

Broken Windows (2)

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-


:If cond ⋄ statement ⋄ :EndIf

Diamond -2-

mat←make 1 2 3 ⋄ mat←Process mat ⋄ mat←1↓[1]mat

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