Scope (large -> small) : Repository > Store > Factory > Others
Class Name | Read | Write | Comment |
---|---|---|---|
store | Y | Y | Provide cache machanism. imply signlton pattern |
repository | Y | Y | the same as store , but repository have more features rather than the read/write data, e.g, update/delete data, provide metadata to archive some business goal, e,g. latest update time, sorting the items based on some rules. |
source | Y | N | get the results when calling it |
provider | Y | N | provide the real implementation, we use it when we try to inject the dependencies(eliminate it) |
factory | Y | N | imply Factory pattern, reduce the complexity of creating objects |
creator | Y | N | might the same as Factory(eliminate it) |
Actually I would disagree somewhat with
Store
. In the Redux sense of the it does imply a Singleton pattern, but it has nothing to do with Caches. If the primary function of something is to be a Cache it should be calledCache
. I think the Redux sense of it is more about "single source of truth/state".That said, in general usage, I prefer the philosophy of asking "what does it do?" (notice I always ask that during review meetings). If the answer is "it stores X", then sure, call it
XStore
.(There is also the meaning of "Store" that sells things, such as "StickerStore", but that's another story).
Repository
is more accurate.Source
the issue is not who calls it, but that it produces a series of things.Factory
is about abstracting the construction of instances, whether for Dependency Injection or because the construction is complex.