I have an old puzzle, so I thought that sharing it with you might be right. The fact is that some of our entities in the database are quite large (reading has many properties), and rarely business logic uses all the properties of the entity, so every time I need to think which properties should be loaded for the business logic to work correctly. A very hypothetical pattern:
public class Product { public string Title {get;set;} public string Description {get;set;} public string RetailPrice {get;set;} public string SupplierId {get;set;} public Supplier Supplier { get;set;}
It looks like I can extract the IDiscountProduct and ISearchResultProduct interfaces, mark the product as implementing these interfaces, and then create smaller DTOs that implement each of these interfaces, but at the moment it looks like iterating over (at least I haven't seen anyone either grouped properties using interfaces).
Splitting an object in the database into smaller objects also does not seem reasonable, since all these properties belong to the product, and I'm afraid that I will be forced to use many connections to select something, and if I decide that some property belongs to another object , this move will be quite difficult to implement.
So that each property used in a particular business logic of the method as a parameter of the method also looks like a bad decision.
Giedrius
source share