Structuring code
We can now begin our journey of building a web application. In the rest of this chapter, we will not touch a web framework or build an HTTP listener. This will happen in the next chapter. However, we will construct a to-do module that will interact with a JSON file. It is going to be structured in such a way that it can be inserted into any web application that we build with minimal effort. This to-do module will enable us to create, update, and delete to-do items. We will then interact with this via the command line. The process here is to explore how to build well-structured code that will scale and be flexible. To gain an understanding of this, we will break down the building of this module into the following chunks:
- Build structs for pending and done to-do items.
- Build a factory that enables the structs to be built in the module with minimal clean input.
- Build traits that enable a struct to delete, create, edit, and get to-do items.
- Build...