16.1. Managing larger programs¶
At the beginning of this book, we came up with four basic programming patterns which we use to construct programs:
Conditional code (if statements)
Repetitive code (loops)
Store and reuse (functions)
In later chapters, we explored simple variables as well as collection data structures like lists, tuples, and dictionaries.
As we build programs, we design data structures and write code to manipulate those data structures. There are many ways to write programs and by now, you probably have written some programs that are “not so elegant” and other programs that are “more elegant”. Even though your programs may be small, you are starting to see how there is a bit of art and aesthetic to writing code.
As programs get to be millions of lines long, it becomes increasingly important to write code that is easy to understand. If you are working on a million-line program, you can never keep the entire program in your mind at the same time. We need ways to break large programs into multiple smaller pieces so that we have less to look at when solving a problem, fix a bug, or add a new feature.
In a way, object oriented programming is a way to arrange your code so that you can zoom into 50 lines of the code and understand it while ignoring the other 999,950 lines of code for the moment.