I've been interviewing a lot of .NET programmers lately and I haven't met one that knows what IDisposable is or what it is used for. Is it really unreasonable to expect someone with 4-6 years experience to know that?
I wouldn't think so. If you don't understand what IDisposable is, how can you appropriately understand when to use a using
statement?
My guess would be that a lot of people know to put certain code in using statements, but don't know why which is rather scary.
I'm quite surprised that the knowledge of IDisposable is too low. Whenever you have a resource that must be closed, and you don't use the using statement, you have to use IDisposable.
Nope, sorry. If they don't know IDisposable
, they don't understand object lifetime in .NET, so it's safe to assume that they have no idea how GC
works. For someone who claims 4-6 year experience, he's either a "drag-and-drop" developer, or a liar. Either way, no hire.
Having just had a job interview today I wish I had been asked a question like that! All programmers should know about IDisposable. It's arguably the most important interface to understand because of the using
statement.
I find it unthinkable that a programmer with 4-6 years experience doesn't know about this.
I would expect developers with that level of experience to know IDisposable. However, it is a complex subject, if you want to dig into all the details. Joe Duffy wrote a rather elaborate post on the subject some years ago. I wouldn't expect all developers to be able to cover all the gory details in that post.
Yes, it is unreasonable. Few programmers that are college age level + 3 to 5 years (the always preferred candidate) have ever written pure Win32 code to know what an "unmanaged resource" looks like. It doesn't typically ever come up in their college years, Java is the teaching language nowadays, a language that doesn't have the same pattern.
There are a large number of .NET programmers that have written .NET code for years and shipped production code without ever disposing anything. I'd recommend other interview questions:
- Why does Java not need the IDisposable pattern?
- Why do .NET programmers get away with never disposing anything?
That tests for insight rather than rote programming. Perhaps more appropriate for the second interview?
It's not unreasonable to expect somebody to understand IDisposable
, but I've also noticed that here on Stack Overflow, IDisposable
-themed questions are second only to Linq questions in terms of their frequency of occurrence. It's plainly obvious that far too few programmers truly understand everything they should about this, and I'm honestly not sure why; it can't be that they're all unqualified, I think it's just that there's too little education on it.
For those of us who came from Delphi or C++ and have had to do manual resource management in the past, this is blindingly obvious, but for people who learned in Java or Python or even VB, not so much. And you'll never get a compiler warning if you forget to Dispose
an object; if you're self-taught as far as .NET programming goes, you could easily go for years without realizing that it's actually a problem.
So with that in mind, I wouldn't immediately fail somebody in an interview if they didn't understand the meaning and proper usage of IDisposable
, but I would consider it a red flag, like so many other things. It's not nearly as bad as (for example) not knowing how to traverse a tree structure or being unable to write FizzBuzz.
I think it's a good question to ask, and if somebody had never heard of it before, I would probably give a very quick explanation and then ask a follow-up question: "The .NET Garbage Collector can only manage memory. IDisposable
lets you explicitly free other kinds of resources. Can you think of any resources that would fall into this category?" If they can't answer that question either, then I'd be worried, because it would indicate ignorance not only of a specific interface in the .NET Framework but of resource management in general. Even if you were taught Java in school, you ought to understand that you need to close files and connections that you open.
Another red flag, perhaps an even bigger one, is if somebody says that you need to put every IDisposable
in a using
block but can't explain why or list any exceptions to the rule (i.e. factory methods). That's worse to me because it could be an indication of cargo-cult programming tendencies.
So keep asking the question, but maybe temper your responses. Don't end the interview immediately if somebody can't answer it. Consider that a .NET programmer never actually has to learn this in order to write functioning (albeit buggy) software.