I have been working on a project where I have a Worker class that generates a lot of data in a multi-threaded fashion. The type, size, and location of the data is variable based on a large set of parameters that can be set by an end user. Essentially this is a big test harness that I am using to investigate how certain things perform based on a variation of the data. Right now I have at least 12 different parameters for the Worker class. I was thinking about switching over to a separate WorkerOptions class that contains all of these values, and then have the UI create the WorkerOptions object and then pass that into the Worker. However, I could also expose public properties on the Worker class to allow the options to be set appropriately at Worker creation as well.
What is the best way to go about this, and why? I am sure this will generate some different opinions but I am open to listen to debate about why different people might do it a different way. Some things to consider are that currently once a Worker is created and running, its configuration doesn’t change unless it stops. This could be subject to change, but I don’t think it will.
EDIT
I am not a C# developer normally, I know enough to be able to write applications that function and follow common design patterns, but my expertise is in SQL Server, so I might ask follow up questions to clarify your meaning.
I’d combine the two approaches.
Make your WorkerOptions class use a constructor that requires all the required parameters, and allows the optional parameters to be set either via an overload, optional arguments, or properties, then pass that in as an argument.
Having the WorkerOptions class gives you a nice DTO to pass around in case refactoring leads you to create an additional layer between the UI and the worker class itself. Using required parameters in its constructor gives you compile-time checking to prevent runtime errors.