I am writing updaters for my component-store.
The situation is as follows:
- I have an Array Of models named processingStatuses.
- Sometimes t I have to update all of them.
- Sometimes I just want to update one of them.
I am wondering which design is better.
- Separate this into 2 functions.
readonly updateOneProcessingStatus = this.updater(...);
readonly updateProcessingStatuses = this.updater(...);
- Always pass the whole array to the updater.
When I want to update one, I get the array from the old state, modify it and then pass it to the
updateProcessingStatuses()
.
readonly updateProcessingStatuses = this.updater(...);
And I also want to know if my naming is acceptable or not. (e.g. plural)
Thanks!
CodePudding user response:
In my view, it is better to create two functions update()
and updateRange()
. By doing this your API will be cleaner and when new developer will try to update, then she/he will have clear understanding what method should be used.
In addition, it can be seen that this approach is used in Entity Framework. UpdateRange() and just simple Update() method