Skip to content

Methods vs COND

Ashok Khanna edited this page Jan 3, 2022 · 1 revision

Using methods & method specialisation, we transfer the selection of a particular case onto specialisation process / lambda list vs. within the body of the function in a COND statement

Where there are few COND statements with quite a bit of detail in each, it makes sense to split them into methods so that the function doesn't become too complex

Where there are many COND statements with only one line in each, perhaps a COND approach is better than spreading across methods (think over the extra overhead of defining a method for single line COND statements)

One of the interesting things with generic functions and writing at a higher level is that a lot of the decisions around which branch of a control flow to go, can be pushed down and down to the lowest levels of the algorithm because we can group the commonalities across algorithms on different branches to the higher level, leaving only the differences -> which if you keep repeating this process, gets pushed down until it can't seem to anymore

Clone this wiki locally