Page 386 -
P. 386
custom widgets and classes
Create code for each track as a function
You could just copy and paste the code several times for each track. But
duplicated code is a bad idea, because it can lead to all sorts of problems
whenever you need to change how the code for each track works. Instead of
duplicating code, you should always try to reuse it.
One way to reuse code is by creating a function that will generate the widgets
and the event handlers as needed.
A function, when called, could
create the interface for a
single track as needed.
If you have a function that creates the widgets and event handlers for a single
track, you could call it for each of the tracks, which would then quickly let you
build the entire interface.
But what code would you need in such a function?
you are here 4 351