Abstraction barriers make programs easier to maintain and to modify. The fewer
functions that depend on a particular representation, the fewer changes are
required when one wants to change that representation.
If you want to change selection, open document below and click on "Move attachment"
2.2 Data Abstraction(x) * numer(x), denom(x) * denom(x))
Assuming that rationals are represented as two-element lists would violate two
abstraction barriers.
>>> def square_rational_violating_twice(x):
return [x[0] * x[0], x[1] * x[1]]
<span>Abstraction barriers make programs easier to maintain and to modify. The fewer
functions that depend on a particular representation, the fewer changes are
required when one wants to change that representation. All of these
implementations of square_rational have the correct behavior, but only the
first is robust to future changes. The square_rational function would not
require updating ev Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details