Design Patterns & Language
We should create a design patterns document for standardized design patterns and associated language which are used within Tendermint/Cosmos. Off the bat, a few features which I think should be discussed here include:
- Mappers/keepers design pattern
- Using
Ensureto express conditional update functions (a function which may update something depending on a condition) - ref https://github.com/cosmos/cosmos-sdk/pull/1858#discussion_r208316437 - Use of aliases for easy importing at the package level (ref https://github.com/cosmos/cosmos-sdk/issues/1123 / https://github.com/cosmos/cosmos-sdk/issues/1124)
Could maybe be placed in go/ dir but this repo needs to be reorganized heavily anyways
I think this will only be beneficial if there is some documentation on what the design pattern means. (At least a link of a blog post of some developer somewhere.)
For example: Use contexts where possible: https://blog.golang.org/context Use pointer method receivers where possible: https://nathanleclaire.com/blog/2014/08/09/dont-get-bitten-by-pointer-vs-non-pointer-method-receivers-in-golang/
etc... (I know that the examples are very basic.)