Loose coupling

Whenever possible, reduce coupling or dependence in your program. The following is a famous quote on this subject:

All problems in computer science can be solved by another level of indirection. – David Wheeler

Let's suppose that your program has a play button. An immediate impulse may be to link it to the play method of your program. However, you can further break it up into two methods. You could probably link the play button to a method named on_play_button_clicked, which in turn calls the actual play method. The advantage of this is that you may want to handle additional things when the play button is clicked, such as displaying the current track information somewhere in your program.

Thus, you can now use the on_play_button_clicked ...

Get Tkinter GUI Application Development Blueprints - Second Edition 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.