Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 11
    A co-worker made a breaking change in code not covered by tests, and you think the problem is var? The language cannot be expected to protect against that sort of behaviour--what if they'd modified MyFirstObject directly? It would still have broken, but no syntax could have saved you from that. I'd consider this a strength of var, even: what if instead of returning MySecondObject you were now returning IMyFirstObject instead? Commented Aug 15, 2012 at 11:31
  • 2
    "Everybody "knows" that GetMeAnObject returns a MyFirstObject, so there's no point checking that." I can't actually think of a scenario in programming where I would actually depend on my memory of what GetMeAnObject if I am debugging. If I checked that PerformOperation is not there, I would have seen the code and no it is for another class. If in an IDE the class would pop up the instance I look at the type of the object. Actually, when the compiler tells me the error, it would say 'class MySecondObject has no operation PerformOperation'. How is that for everybody knows? Commented Aug 15, 2012 at 13:27