Finalizing the data structure
As Linus Torvalds, the developer of Linux, once said:
"Bad programmers worry about the code. Good programmers worry about data structures and their relationships."
What he means is that well-designed data structures make the code very easy to design, maintain, and scale up. In contrast, if you start with a poor data structure, you can't make up for that, even with the best of code.
Start with a good data structure and your code will naturally be more simple, elegant, and easy to maintain.
With that in mind, let us try to decide on a suitable data structure for our program. Go back and take a look at the previous figure (under the An overview of the chapter section).
What kind of data structure do you think would be needed to capture all the necessary fields of information?
Well, first of all our Drum Machine needs to keep information about beat patterns. So let us start by creating list named all_patterns = []
.
Now, each of the patterns within the list needs to capture...