C
C#16mo ago
dotnut

❔ comples object creation

Hi people, Can someone give me some ideas on how to handle a complex object creation, meaning some of properties are objects which themselves and are pretty tricky to create too, one of which even requires data from an I/O operation for which I consider injecting a service for. If I instantiate the properties in the constructor the constructor itself becomes quite huge. I tried the builder pattern but not too fond of it.
4 Replies
ero
ero16mo ago
how complex are we talking?
dotnut
dotnutOP16mo ago
All of the properties are objects Around 10 Some data from a property is used in instantiation of another One requires getting some data from a file I want to construct it in a way that can be reused by other classes where some bits and pieces will be different But it’s the same blueprint
Denis
Denis16mo ago
Maybe you could create a record to represent the data, fill it in, then pass it as the argument value to a class that handles the logic With a record you can set it's values using properties.
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server