We have a use case where there is a class that has more than 130 attributes. There is a method that populates all the attributes and it is just very long just because of large number of attributes. Just the setters would make the method very long.
Just to give context about the source for these attributes, these are populated by different datasources. Few of them are from different micro services and few of them are from a mysql tables.
Our current solution is to group them into different groups based on the source or some similar business trait and update them in different methods. This has made some of the setters in different methods and just makes it very hard to read.
I have read else where about the builder pattern. But most of these attributes need some transformation after fetching from source and assigning each of the attributes to a temp variables and using them in the builder doesn't help much.
Aucun commentaire:
Enregistrer un commentaire