Building the basic application structure
There are two main reasons to define a good basic structure for our application:
- It keeps our code organized
- It allows us to reuse pieces of code in later applications
Python is a flexible language in terms of code organization, and although users are allowed to write the whole application in a single file, it's preferable to separate the functionalities into modules and packages.
Modules are Python files that contain classes and functions that can be imported into another file with the import statement. Packages are special directories (folders) that contain modules. This leads to organized and well-structured code that is less prone to having bugs and is easier to maintain.
The proposed structure is to have a folder for each chapter. Inside it, we can create packages or files for each application; we will create a package for a common utility code that can be imported and reused and a directory to perform experiments.