Skip to main content
4 events
when toggle format what by license comment
Nov 17, 2014 at 9:58 comment added InBetween I understand, the question is: I create a CsvWriter with a specific CsvWriterSettings. Then after a while, I mutate CsvWriterSettings. What happens to the initialized writer? Should it mutate its behavior? Should it ignore the changes? Both options are not obviously right, so I want to avoid this alltogether by making CsvWriterSettings immutable. You are right concernig the fields initialization, I just need one CsvWriterSettings field. The code stands as it does because initially CsvWriterSettings was mutable and I had decided to ignore mutations once the writer was created.
Nov 17, 2014 at 9:45 comment added BCdotWEB All I'm proposing is that you have a private readonly CsvWriterSettings which you assign via the contructor; I don't see how that one can be changed between calls.
Nov 17, 2014 at 9:39 comment added InBetween The point of doing it this way is because CsvWriterSettings is immutable. I don't want anyone changing settings once the writer has been initialized; what you are proposing would allow changes to the writer's behavior between calls to WriteLine(T value) or WriteLines(IEnumerable<T> values) which could create inconsistant csv files. Still I agree that the code is unecesarily verbose. I should just store the CsvWriterSettings object in a readonly field.
Nov 17, 2014 at 9:15 history answered BCdotWEB CC BY-SA 3.0