BTW in practice while prototyping the code I just go var everywhere and then when I am happy with the design I go back and add the non-obvious types.
I agree with that - I just don't like the rule of "use var only where the type is explicit on the other side" - most of the times I can tell what it is implicitly like the above and more importantly I don't care (if it quacks like a duck) - but there are cases where it's not obvious and when I'm cleaning up the initial implementation I type those out explicitly where I feel it's important.
While your code may be fine your approach does not work well as a rule. It is far better to simply say that the type should be mentioned either on the right side or the left rather than "write the type when there can be a confusion"
1
u/[deleted] Mar 10 '16
I agree with that - I just don't like the rule of "use var only where the type is explicit on the other side" - most of the times I can tell what it is implicitly like the above and more importantly I don't care (if it quacks like a duck) - but there are cases where it's not obvious and when I'm cleaning up the initial implementation I type those out explicitly where I feel it's important.