exactly one job identifiable with a short name and characterizable in a single line of text.
Tags
#python #sicp
Question
Each function should have [...]
Answer
?
Tags
#python #sicp
Question
Each function should have [...]
Answer
exactly one job identifiable with a short name and characterizable in a single line of text.
If you want to change selection, open original toplevel document below and click on "Move attachment"
Parent (intermediate) annotation
Open it Each function should have exactly one job identifiable with a short name and characterizable in a single line of text.
Original toplevel document
1.4 Designing Functions mall, and
serve as our primary medium to express computational processes in a programming
language. So far, we have discussed the formal properties of functions and how
they are applied. We now turn to the topic of what makes a good function.
<span>Fundamentally, the qualities of good functions all reinforce the idea that
functions are abstractions.
Each function should have exactly one job. That job should be identifiable
with a short name and characterizable in a single line of text. Functions
that perform multiple jobs in sequence should be divided into multiple
functions. Don't repeat yourself is a central tenet of software engineering. The
so-called DRY principle states that multiple fragments of code should not
describe redundant logic. Instead, that logic should be implemented once,
given a name, and applied multiple times. If you find yourself copying and
pasting a block of code, you have probably found an opportunity for functional
abstraction. Functions should be defined generally. Squaring is not in the Python Library
precisely because it is a special case of the pow function, which raises
numbers to arbitrary powers.
These guidelines improve the readability of code, reduce the number of errors,
and often minimize the total amount of code written. Decomposing a complex task
into concise functions i
Summary
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.