Coffeehouse Thread

60 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Interviewing programmers

Back to Forum: Coffeehouse
  • User profile image
    Charles

    What does the keyword virtual mean? When would you use it?

    When would you use an abstract class over using an interface?

    What can you do to ensure that your objects are properly disposed of by GC?

    What happens when you call GC.Collect()? Why would you call it? What's the cost? What happens?

    Implement ToString()

    C

  • User profile image
    bgmacaw

    My approach

    Start off by asking a few softball programming trivia questions that anyone with any experience should be able to answer. If they fail these simple questions, it's obviously time to say "Next!". 

    Then follow up by asking them to describe the project they're currently working on and some of the specific techniques they're using. Ask them specific, open ended, questions about it like, "Why did you use generic List rather than an array?" or "How did you decide that XML serialization was the best approach?" The idea is to get a taste of how they organize their thoughts on familiar ground.

    The last part, if they've done well so far, is to present them with a sample problem that fits within your domain. For example, let's say you load a lot of oddly formatted raw data files into database tables. Ask them how they would approach the problem and have them pseudo-code out their solution. This will give you an idea of how they think when presented with something new.

    You can also ask off-beat thinking questions like "Everybody knows why manhole covers are round but why are septic tank covers square?"


  • User profile image
    littleguru

    Mine does not have one

    public class LittleguruFoo
    {
        public new bool ToString
        {
            get { throw new NotImplementedException("I don't have a ToString method!"); }
        }
    }



    Hehe Wink

    Foo f = new Foo();
    f.ToString(); // Compiler error.

    object f2 = new Foo();
    f2.ToString(); // Now I have one again. Holy cow, I can't escape.

  • User profile image
    blowdart

    Ion Todirel wrote:
    
    Dr Herbie wrote:
    "What is polymorphism and why is is useful?"

    I was shocked at the number of candidates that couldn't separate polymorphism from class inheritance and I don't think I've met one yet who could explain why it was useful (other than inheriting functionality, which is not the correct answer).


    Also, for C#, ask them to explain garbage collection.


    Herbie
    good questions, also you may ask when Dispose method is called


    And if that supports deterministic finalisation. Then ask about the Dispose pattern. (which is what i do, and did today)

  • User profile image
    blowdart

    Charles wrote:
    What does the keyword virtual mean? When would you use it?



    How does new differ from override; best illustrated by a piece of sample code; where each class has a Message method printing the class name; then declare all 3 classes as the base type.

    In the last 3 months only 1 person has gotten the final output right.

  • User profile image
    W3bbo

    blowdart wrote:
    
    Charles wrote:
    What does the keyword virtual mean? When would you use it?



    How does new differ from override; best illustrated by a piece of sample code; where each class has a Message method printing the class name; then declare all 3 classes as the base type.

    In the last 3 months only 1 person has gotten the final output right.


    Well you haven't phrased your question properly. Write it out fully and I'll give it a stab.

  • User profile image
    pathfinder

    Dr Herbie wrote:
    
    OK, firstly polymorphism has nothing to do with code-reuse.  That's where you're confusing class inheritance with polymorphism (although you're right, polymorphism does depend on inheritance). Polymorphism can also be done through pure interface inheritance.
    Polymorphism is where different classes can be made to appear the same through casting to a base class/interface. This allows all the references to be treated the same, thereby simplifying code that uses those objects.

    The classic example is a vector drawing program there all the shapes derive from the base 'BaseShape'.  The specific instances of shapes that the user creates (Like CircleShape, TriangleShape and RectangleShape) are stored in a collection of BaseShape instances and the picture is drawn by iterating through all the BaseShape instances and caling the 'Draw' method.  The main program has no knowledge of which shape it is drawing and it treats them all the same.
    The contents of the 'BaseShape' class are irrelevant to the technique of polymorphism; BaseShape may containa lot of shared code, or it may be an interface with no shared code. Polymorphism and code-reuse are two separate aspects of inheritance.


    I had been doing OOP for nearly 10 years before I realised this distinction.



    The next question would be:
    Other than inheritance, how else can you re-use code in an OOP fashion?


    Herbie


    Good points!
    We use polymorphism when we are passing  objects between the different tiers in our application.  Any object that is exposed on the web tier and is passed back to the business tier MUST inherit off of an interface.  The business tier and data access tier MUST use the same interface.    In this case polymorphism is not used for code reuse but instead to keep our heads on straight.  Especially since there are different programmers working in the different tiers.

  • User profile image
    blowdart

    W3bbo wrote:
    




    Well you haven't phrased your question properly. Write it out fully and I'll give it a stab.


    I'll do it in the morning; if someone else hasn't done it.

    Basically in BaseClass have a vitual method Message which prints "BaseClass". In SubClass1, derived from BaseClass override that method and print SubClass1, in SubClass2 new the method and print SubClass2. Now declare 3 variables of class BaseClass, one an instance of BaseClass, one an instance of SubClass1, one an instance of SubClass2. Call Message on each. What gets printed.

  • User profile image
    blowdart

    pathfinder wrote:
    In this case polymorphism is not used for code reuse but instead to keep our heads on straight.  Especially since there are different programmers working in the different tiers.



    Pah, shift to late bound duck typed objects and remove that dependancy on a base object Wink

  • User profile image
    Ion Todirel

    W3bbo wrote:
    
    blowdart wrote:
    
    Charles wrote:
    What does the keyword virtual mean? When would you use it?



    How does new differ from override; best illustrated by a piece of sample code; where each class has a Message method printing the class name; then declare all 3 classes as the base type.

    In the last 3 months only 1 person has gotten the final output right.


    Well you haven't phrased your question properly. Write it out fully and I'll give it a stab.
    i don't know, sounds very clear to me...

  • User profile image
    Johnny​Awesome

    I like questions that let the candidate and interviewer to run with them. It puts people at ease and it only gets as complicated as you want/need it to. So, in their basic form if the candidate can't even answer it to begin with then you do not have to go farther. But as they progress take them down a path and let the conversation kind of build on itself.

    You could white board or on paper (which I hate personally) offer several items and start simple and ask to see them related programmatically. Just a half-dozen objects should be good. Just make sure they are different. So maybe some would be properties like type or color and some are obviously extended from other base classes to anyone who has actually written code. Make sure it's something simple and could go different directions:

    1. Helicopter
    2. Bird
    3. Operator
    4. Dump Truck
    5. Seagull
    6. Green

    If they can't see a seagull and extending bird its over. Maybe they pose a question "Is an operator a person? Can they drive and fly?" Whatever. You should be looking intelligence and problem solving abilities. Posing the right questions and then constucting the answers in C#.

    You could draw out a scenario all the way to building a small app on a white board. What methods would these objects have? How would they work? When?






  • User profile image
    Mark Brown

    I'm with Mr. Awesome here. I much prefer asking programmers questions around, "How would you design or program something" rather than really specific nit-pick topics.

    There's so much an engineer has to know that it's impossible (for me at least) to keep it all in my head. I'd want to see creativity, how they approach the problem. Who cares what the enums for some specific API are, that's what MSDN is for.

    Generally too I find that even just having a casual conversation about software and programming has been enough for me in the past to weed genuine candidates from BS'ers.

  • User profile image
    amotif

    Massif wrote:
    why "this " + someint.ToString() + " is stupid" is a bad idea


    Ooh, good. Are you asking because of the use of ToString() here or because you think there's an inefficinet concat happening--because it's really not. C# 2 will use String.Concat(string,string,string) here. It's probably not any worse than using String.Format.

  • User profile image
    amotif

    Riffing on Dispose:

    a) Why would you implement IDispose?

    b) What's a finalizer?

    c) What should you clean up (or not) when Dispose is called?

    d) What should you clean up (or not) when the finalizer is called?

    e) What's the function that I always forget to call when I implement Dispose? (Interpret as "What's the function you should call when you implement Dispose?")


    How many people do you suppose get c) and d) correct?

  • User profile image
    andy_hanger​18

    Mark Brown wrote:
    I'm with Mr. Awesome here. I much prefer asking programmers questions around, "How would you design or program something" rather than really specific nit-pick topics.

    There's so much an engineer has to know that it's impossible (for me at least) to keep it all in my head. I'd want to see creativity, how they approach the problem. Who cares what the enums for some specific API are, that's what MSDN is for.

    Generally too I find that even just having a casual conversation about software and programming has been enough for me in the past to weed genuine candidates from BS'ers.


    I too prefer this sort of direction when interviewing potential candidates.

    Tell you what, as sad as it seems, I went to bed thinking about this thread last night. I was just about to shut the PC down for the night and thought I'd catch up on the evenings Coffeehouse postings and read this one. Do people really go this nasty and technical in interviews? I think I'd sooner be interigated by Jack Bauer than attend some peoples interviews in this thread Perplexed

  • User profile image
    cheong

    Actually, I'll go through those common question regarding OOP concepts. And then limit my question to those related to the job function.

    Say that I'm hiring a Web Programmer knowing C#, it may not be so important to the interviewee whether he/she knows about IDispose/Finalization or not if our pages don't really touch them, however I'll want to make sure that know something about difference between Profile, Session and Viewstate, and of course, the events and their usage in Page Lifecycle.

    If you're hiring Winform programmer for Database related programs, you'll probably want to ask them if they know anything about how to get things done in commonly used 3rd party tools like Crystal Report, as well as the ability to write SQL statements, or even stored procedures.

    The ideas of best fit questions in interviews come from your currently working projects. Maybe pulling out helper functions that you think you'll able to finish in 5 minutes and ask them to implement in 15 minutes will be good enough.

    Recent Achievement unlocked: Code Avenger Tier 4/6: You see dead program. A lot!
    Last modified
  • User profile image
    Dr Herbie

    andy_hanger18 wrote:
    Do people really go this nasty and technical in interviews? I think I'd sooner be interigated by Jack Bauer than attend some peoples interviews in this thread


    I don't remember all the details for all the .NET framework object, and I don't expect candidates to either. The reason I ask 'nasty' questions is not so much for the answer the candidate gives, but for how they react and handle a question that they don't know.
    If they just answer 'I don't know', or 'I'd have to Google that', then I take that as a positive.  If they bluster and bullsh*t, then I take that as a negative.  If they ask for the correct answer then that's a gold star.

    I prefer not to ask simple answer questions, but questions that could lead to a brief discussion so I can gauge the intellect of the candidate.

    We use sneaky non-technical questions too:

    Recently we've been interviewing for a graduate tester position.  We ask 'Where do you see yourself in three to five years time?'
    If they say something like 'I don't plan that far ahead.' or 'I don't mind as long as I'm learning' then that's fine.  If they say 'Running my own software firm' or (the classic) 'I plan to become a Developer' then that's a bad sign (we're going to train them as testers and they're just intending to use us as a leg up into a different career, thus wasting our efforts).

    It's a bit of a game/battle : we are trying to sell our company to the top candidates because we want good employees while the candidates are trying to sell themselves to us because they want the job.  The interview is where the interviewer and the candidates try and find the complete truth (Does the interviewer have any frustrations about the job? Does the candidate plan to stay for at least three years?  How much overtime does the interviewer really do?  Is the candidate really as smart as they appear in their CV?)

    As an interviewer I try to be open, friendly, and honest, but you can't badmouth company culture/coworkers/bosses/customers/whatever in front of a candidate as it's not professional. At the same time you want the candidate to have a clear picture of what the job is like because there's no point in hiring them only to have them leave after a month when they realise the job is not what was outlined in the interview. So the interview (for me) becomes a subtle game of psychology to try and get/give the truth. Nasty technical questions are a part of that.



    Herbie

  • User profile image
    Minh

    Anyone has an opinion on multi-on-one vs. one-on-one interviews? Personally, I think being interviewed by  many people is fun, but I hear it could be stressful, too.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.