25 July 2006

I Speak In Analogies


I think it's because I'm genetically CHINESE.

Allow me to explain, via a scenario that happened today during my office hours.

************************
Student: I guess I'm still not sure I understand how this whole passing ints work in functions...
Prakash (to me): Want to give it a shot?
Me: Sure... (thinks for a moment)
Me (to the Student): Let's say we're in a bank. You're a customer, and I'm the bank teller.
Student: Ok.
Me: You're interested in knowing the balance in your bank account. What would you do?
Student (confused): Uh, I guess I would ask you.
Me: Ok, let's play out that scenario. "Hi, how may I help you?"
Student: "I, uh, would like to know my balance."
Me: "Your balance is 300 dollars." Now, did you give me anything?
Student: Uh, no.
Me: But did you get something from me?
Student: You told me the balance.
Me: Excellent! We just enacted a function that does not accept any parameters, and returns a double.
Student: ...
Me: Now, let's do something else. Let's say you have something you want to deposit into your bank account. What would you do?
Student: I'd give you a check.
Me: Ok. "Hi, what can I do for you today?"
Student: "I'd like to cash this check."
Me: And what did you just hand me?
Student: ... A check.
Me: I deposit the check into your account and that's it. I don't say what your new balance is or anything.
Student: Ok.
Me: That's a function that accepts a double as parameter and returns a void.
Student: Oh!
Me: Now, if you want to know your new balance, we can change it so that it returns a double, and then I'll tell you what you have.
Student: ... damn, thanks.
************************
You should hear the ones regarding shafting the compiler due to incompatible function declaration...or the moldy bread in produce bags for explanation on local and global scopes. I'm sorry that my students have to suffer through my recitations...

No comments: