The whole point of the last few installments, and the thousands of words (and however much study) accompanying them, has been to separate the domain and persistence layers. Yet I failed to do that.
To persist or load a Task
, the repository needed to turn the domain object to or from the form in which that object is being stored. The domain object is a Task and the persistence representation is a string. The conversion and deconversion ("serialization," in this case) absolutely must be handled entirely at the repository level.
Here I got sloppy and used a convenient mechanism for string representation--the str method on Task
, which was easy to reach for--as the repository-level serialization logic. In doing so, I broke the interface between the domain and repository layers.
Now, someone maintaining the Task
object cannot change that method without its breaking the persistence layer. This is, again, very very bad:
Task
harder to maintain.Task
or TaskRepository
.Task
in a human-readable way.The time to fix a mistake like this is now.
Here is the current commit in the veery/ repository
.
Next post: Python task manager from scratch, part 14: Make an interface