Getting ready

Let's start by defining the MVC pattern and how it maps to the different parts of the application we built in our previous recipe.

This pattern divides our application into three components that encapsulate a single responsibility, forming the MVC triad:

  • The model represents the domain data and contains the business rules to interact with it. In our example, it is the Contact class and the SQLite-specific code.
  • The view is a graphical representation of the model data. In our case, it is made by the Tkinter widgets that compose the GUI.
  • The controller connects the view and the model by receiving user input and updating the model data. This corresponds to our callbacks and event handlers and the attributes needed.

We will refactor our application to achieve this separation of concerns. You will note that the interactions between components require additional code, but they also help us to define their boundaries.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset