Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

How can I explain C# interfaces and constructors to a 8 years old genius kid?

share|improve this question
4  
Are you trying to say that you are an 8 year old genius? Where are my hover cars? –  ChaosPandion Apr 14 '12 at 17:52
add comment

4 Answers

up vote 10 down vote accepted

I would get them one of these toys:

Interface thing

And would make an analogy that the yellow piece on top has holes in it with a specific shape, and the shapes that you are allowed to pass through these holes is a concrete type of that shape. The interface, although is not creating any action on the shape, implies that the shape has to have a few characteristics, like size, how many sides, is it round, etc.

As for the constructor, I'd tell them it's the "recipe" + action of building one of these little toys: (a) It's something that is specific for that type of toy; (b) it can be applied to other toys that are similar to first toy; (c) I can build it slightly different next time, like changing the color or having it's height different from the original height; etc.

So after these analogies, I could point to the code (assuming you're showing code to your kid) showing the interface not interfering with the concrete class behavior, tells the class some of the features it should have, and the constructor of the class is the subroutine of building that type.

Makes sense?

share|improve this answer
2  
+1, Brilliant analogy. I look forward to teaching my daughter using this one day! –  stuartmclark Apr 15 '12 at 6:54
add comment

You point the kid to the appropriate MSDN pages. If he's a genius, it'll suffice ;)

Otherwise sit down with him, write some simple code showcasing both. The same console examples you would show a grown-up. Nothing fancy, just some lines printed in constructors to show how an object graph is created and maybe the classic animal example for the interfaces (the one with different animals implementing a Speak or Move method).

If the kid is genuinely interested in programming, that will keep him entertained. If he'll lose interest after a few minutes, let him be. Have a normal childhood. Give him the "interface talk" when he'll grow up a bit.

share|improve this answer
    
+1 for "interface talk"! –  ell Apr 14 '12 at 23:52
add comment
  • Interfaces - the bumps on Lego/Mindstorm pieces, allowing you to connect bits to each other easily

  • Constructors - A method that prepares the object for usage, so perhaps a cooking analogy is a good one. Adding boiling water to soup powder in order to make soup?

share|improve this answer
    
Continuing with the Lego metaphor, constructors would be the instruction booklet. –  System Down Apr 14 '12 at 16:02
add comment
  • Interfaces - The buttons and the volume tuner from the 90's on a TV - the part you use for interaction. You can change or the fix the internals of your TV when it breaks after the 2 year warranty is over while leaving the interface intact.
  • Constructor - A special method that gets called every time the object instance from a class is created (If you're explaining interfaces to him(?) than he propably knows what an object and a class is).
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.