We will take the example of a contact list application to illustrate how to model our data using Python classes. Even though the user interface may offer lots of different functionalities, we will need to define what attributes represent our domain model—in our case, each individual contact.
Structuring our data with a class
Getting ready
Every contact will contain the following information:
- A first and last name, which must not be empty
- An email address, such as john.doe@acme.com
- A phone number with the (123) 4567890 format
With this abstraction, we can start writing the code of our Contact class.