Data: FileDao
Opened this issue · 1 comments
Create a simple DAO, which can be a little enhancement to InMemoryDao
:
- loads its contents from a file serialization, e.g.
yaml, json, ini
- returns immutables (which is good, right?)
- don't allow to mutate the data (LSP abuse?)
Ok, being rightful to Liskov Substitution Principle (LSP), we shouldn't make FileDao
a subclass of InMemoryDao
in spite of all the similarities between them. If FileDao
is to represent immutable contents of a config file, all the mutating methods of IDao
/IQueryChain
are becoming fruitless and should be turned into raise NotImplementedError
. On the other hand, this solution makes subclassing breaking the LSP -- you can't use any method that would update
the DAO contents, which as a result would force the developer of the Repository
to know what type of DAO will be used and that is contrary to the DI pattern.
One can conclude that either FileDao
entries as mutable, or we have to make IReadOnlyDao
/IReadOnlyQueryChain
and to make sure that DI pattern recognizes subclassing between fields:
dao: IReadOnlyDao == TinyDbDao() # or sth like that
Acceptance criteria for this issue are to be described later.