Closed sadqiang closed 6 years ago
I like it. Definitely a lot simpler. 👍
After thinking about this more, I don't want to show the simplest types. Here's my opinion:
There is a tradeoff here between using the simplest/primitive types in the interface, and reducing update churn later. Let's say that I later decide to make DueAt
a required paramter of AddItemAsync
. If it is a primitive parameter, I'd have to update the interface and also update any implementations of this interface (including tests/mocks). On the other hand, by using the class type, I have more flexibility down the road without requiring potentially breaking interface changes.
There definitely are counterarguments to this, and a lot of this comes down to personal preference (IMO). For this book, I'm going to show the more flexible style.
The current definition of ITodoItemService is as follows.
As ITodoItemService is specifically intended to operate on
why don't we define ITodoItemService with the simplest types as follows?
The simplest types represent a type of TodoItem and/or types of properties defined in TodoItem class.
The advantage of my proposal above is that ITodoItemService depends only on TodoItem type and the built-in .NET types rather than ApplicationUser class or others.