Toxy
Toxy copied to clipboard
Restrict access to MessageData internals
Save for the message string - which is modified during url filtering - no property of MessageData is modified after creation, hence I changed them to be readonly. This approach forces developers to explicitly initialize the object instead of being able to rely on default values. I used named parameters during initialization in order to avoid confusion since there are a lot of bools which have to be passed.
Wouldn't { get; private set; }
suffice too?
I'm sure it would suffice, however a private setter is a bit less restrictive since an instance can still change its own variables, which it can't do when they are readonly. I am under the impression that immutability is considered "good" practice, which is the reason for this pull request. That being said, it does make the code more complex, so you will have to weigh the advantages and disadvantages when deciding wether you will merge or not.