When writing constructors, I regularly encounter a situation where some fields already have approperiate (default) values, such as false for boolean values and 0 for integers. What are reasons to emphasize these values, for example like:state = 0;Do you appreciate it when reading someones code? On one side I feel like expressing implementation details explicitly, on the other side I find it pointless to set a field when I'm sure it is already correct.
Setting fields with correct default value
c#;.net
I work in a projects company. I LOVE it when default values our explicitly defined in the code. This also implies:1. Definition of the data - is the data type used correct ?2. The semantic definition of a value - Like in your example, 0 is a clue for an initial state. In some cases I get no clue what 0 means.Note :State MUST be defined somewhere, be it a CONST value, or an enumeration somewhere. The value 0 has no other meaning than initial state. A string literal might add some more value to it.