When working with service-oriented applications, we often use system types to identify / query our business objects.
IList<Product> GetProductsByUserAndCategoryId(int userId, int categoryId);
However, we cannot prevent developers from passing another identifier that is not a "User Identifier" and not a "Category Identifier", or, possibly, inverts the identifiers when the method is called.
Thus, the solution is to use strong type identifiers, for example:
IList<Product> GetProductsByUserAndCategoryId(UserId userId, CategoryId categoryId); GetProductsByUserAndCategoryId(new UserId(123), new CategoryId(456));
What do you think about this? Pros and cons?
source share