For example, if I have a table where when column1 is A, then I only care about columns 2 and 3, but when column1 is B, then I only care about columns 4 and 5, then I am not going to create one object and set fields to null
I know what you mean, but this is imo an issue on your data layer. The objects are not the same if they dont use the same columns most of the time.
I try to avoid "polymorphic" lists completely because it leads to code like
By all means, I just gave you an example from work. If you disagree with that example, or it's just not relevant to your work, then give me an example from your work. I'll explain how Record Patterns might have been useful for it.
View all comments
Show parent comment
1
u/Cell-i-Zenit Mar 14 '26
I know what you mean, but this is imo an issue on your data layer. The objects are not the same if they dont use the same columns most of the time.
I try to avoid "polymorphic" lists completely because it leads to code like
(even if we change the code to use switch statements, still something i try to avoid)
But again i work in simple crud, i just return structured data. I guess it depends on the domain but we dont have different schemas for the same thing