Abstraction
Abstraction is another very general programming pattern that applies to more than just modular programming. Abstraction is essentially the process of hiding complexity: separating what you want to do from how to do it.
Abstraction is absolutely fundamental to all computer programming. Imagine, for example, that you had to write a program that calculates two averages and then figures out the difference between the two. A simplistic implementation of this program might look something like the following:
values_1 = [...] values_2 = [...] total_1 = 0 for value in values_1: total = total + value average_1 = total / len(values_1) total_2 = 0 for value in values_2: total = total + value average_2 = total / len(values_2) difference = abs(total_1 ...
Get Modular Programming with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.