solid
A walk-through of improving an example "Message Store" to demonstrate SOLID principles.
Tutorial
There is documentation to read in the code if you want to go at your own pace.
Otherwise you can follow the tutorial in the
associated gitbook here
Getting started
After cloning the repo, you can run the final example using make run
.
Example:
git clone [email protected]:diversemix/solid.git
cd solid/message-store
make run
Exercises
Some thoughts on exercises - to be talked about with the team.
- Use the class
CompositeStoreWriter
defined in the filecomposite-store-writer.ts
to replace the use of the decorator pattern to use the composite pattern. - Create an implementation of
ICacheLogger
and use it to replace the cache's use ofIStoreLogger
. - Reading from a non-existant file in the
FileStore
class can throw an error, come up with a solution that will log this within the current architecture. - Create an implementation of
IStore
that saves the messages into a sqlite in memory db. - Implement the
Factory Pattern
to switch on which implementation ofIStore
to use. - Create tests for the implementations of
IStore
.