Sometimes I have a hard time understanding the "verbs" or method names of OOP these days.
Note the following is just to use Redux alone, without the mechanism of hooking it up with React.
For example, in Redux, if you use the most basic form:
store = createStore(reducer); store.dispatch(action); store.getState(); store.subscribe(fn);
For quite some time, I didn't quite get it what
dispatch() means? The store "dispatch" something, like the store is sending out something?
So later on, I found that the method names are from the "I" perspective:
- Store, I want to dispatch an action to you
- Store, I want to get state from you
- Store, I want to subscribe to you with an observer (or listener)
If we use the Smalltalk way of naming, which is one of the earliest object oriented programming languages, it is:
store.takeAction() store.giveState() // or store.state() store.addEventListener()
It goes naturally:
- Store, take this action
- Store, give state to me
- Store, add an event listener
You can see
window.addEventListener() is using such naming too.
Did I misunderstand something? Not that I want to nitpick... but it is the use of some terms that can make me confused for quite a while, and then I found out, "oh... the name... it actually is from the perspective of the user of the object, instead of a verb or message to send to the object." (for a long time, I thought the store is to dispatch or send out some action to some where).