ANONYMOUS wrote:
>
> Hi,
> the marking rubric assesses the
> > Use of functions to perform **distinct actions** to query or update data
>
> I understand that it is effective to use functions to prevent re-using of the same code.
> However I was wondering if it is better practice to use a function to perform a **distinct action** (lets say 10-15 lines of code) even if the action would be completed only one time? Or is it acceptable to just write the 10 lines of code without a function.
As we are not striving for any efficiency, highly readable code is greatly preferred over long sequences of code that, often, are longer than the screen you're reading from. For example, The Clarifications define the order of scheduling in the execute_commands() function, as:
unblock any sleeping processes
unblock any processes waiting for all their spawned processes (children) to terminate
unblock any completed I/O
commence any pending I/O
.....
which *could* be written as 'one long' sequence of code, or as the more readable:
unblock_SLEEPING();
unblock_WAITING();
unblock_completed_IO();
start_pending_IO();
[And from 1977, a very famous paper: 'Debunking the “expensive procedure call” myth.....'
https://dl.acm.org/doi/10.1145/800179.810196 )