Structuring code
Structuring code is an important part of developing any web app. Because of this, we have to get comfortable breaking down a problem into components that Rust can manage and execute. For our exercise, we will create a simple to-do program where we can create, update, and delete to-do items via a command line. This is a simple app. The process here is to explore how to build well-structured code that is scalable without getting into the weeds of the complexity of the logic of the app. In order to build this well in Rust, we are going to have to break the processes down into chunks:
- Build structs for pending and done to-do items.
- Build a factory that enables the structs to be built in the
to_do
module. - Build traits that enable a struct to delete, create, edit, and get the to-do items. These are then imported into the factory so that the pending and done structs can implement them.
- Build a read and write to file module to be utilized by other modules...