Appropriate Use of Type Inference or (2 var | ! 2 var)

Type inference is a new C# feature allowing one to declare variable in a type safe way, while “saving typing”. As it is a new feature, there are still going debates (sometimes heated) about appropriate uses of type inference. When to use Type Inference on jaredpar’s WebLog represents the “use it whenever it’s possible” camp, while Appropriate use of Local Variable Type Inference on B# .NET Blog (really nice blog indeed!) represents the “use it only when it’s absolutely clear what the type is” camp. My view coincides with that expressed in the latter article, i.e. “use it only when it’s absolutely clear what the type is”. Especially, one starts to value this approach in case one has to read the code written by someone else: it is sometimes (usually?) difficult to grasp what that code is doing, and then on top of that one has to figure out what are the actual types of variables. Brrrrrrr…

Advertisements

One thought on “Appropriate Use of Type Inference or (2 var | ! 2 var)

  1. Hi Roman,

    Thanks for linking to my blog (and sharing my opinion ;-), although I’m very flexible concerning people’s own opinions). As usual, new features cause some controversy and discussions but that’s a good thing obviously.

    -Bart

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s