I need to create an immutable object but it requires several parameters to work like:
class FooRepo
{
public string ConnectionStringName { get; }
public string SchemaName { get; }
public string TableName { get; }
public Dictionary<string, int> ColumnLengths { get; }
public Dictionary<Type, SqlDbType> TypeMappings { get; }
// some queries...
public IEnumerable<string> GetStrings(object param1) { ... }
}
I find there are too many parameters to pass them all via the constructor (I might add more later).
The idea of locking the object after it's been setup doesn't sound good either.
I thought about creating a FooBuilder
but this would only hide a huge constructor.
The only resonable solution I can think of is to define default values for some properties like ColumnLengths
and TypeMappings
and allow the user to override/customize them by deriving from the original class.
What would you say? Or maybe there are better ways for such a task?