Thursday, March 29, 2012

Function(al) Developers

There are only 30 more minutes to end this very important day. Today my son wrote his last exam in his schools life. And the exam was Computer Science. It is this very day I was waiting to start my blog. Apart from this I met with another depressing incident today. I see both are connected.


Last year when I saw my sons text book on Computer Science (OO with C++) i was thrilled and started flipping through the pages. Then I decided that i would not teach him anything related to either OOP or C++ (not that he was interested in earning from me).


The depressing incident was interviewing a fresher (BTech - Information technology) who has a 8+ CGPA. How are these 2 things connected? Well read on!


When ever i visit campuses for recruitment (most of times I do management round which after technical round) I casually ask the students to "Write a function in C which takes 2 integers and returns the sum of those two".


Most of the people would immediately say that they had done C programming long ago! (actually in their first or second year in college) And believe me we will be seeing them in their third year. So, I ask them "Why dont you try it in Java then?". 


Mostly almost 90% of the people after a 5 to 10 minutes persuasion will start writing a "main" function with a "printf" s to prompt followed by a couple of "scanf"s to read values for a and b and calculate "c=a+b;" then print c.


Then I tell them that this is not what i have asked for. And what I have asked for is a function with just one line of code in it. Believe me I have seen only less than 10% of the people doing this after almost 10 minutes of talking and explaining what a function is.


Unfortunately today, the candidate was just refusing to understand what a function is and not even able to identify the function name and return type after i wrote the function myself.


I had a greater challenge when I was training fresh graduates in making them unlearn things.
It is not the old procedural C which is getting this kind of treatment. OOP languages like Java also will come in a different flavor during these interactions. For them

  • Class is a collection of Objects
  • Inheritance helps them to reuse the code
  • Encapsulation is wrapping data and function in a nice gift wrap called class etc.

One student went to her dormitory and fetched the book that taught her "class is a collection of objects" in the middle of the interview.


When it comes to encapsulation, this is not the wholly owned property of OOP. The word came into effect when the first subroutine (todays function or method) was written. 


A well encapsulated function is like a maths problem. When you solve a maths problem before selecting and using a formula you need to find 

  • what is given and
  • what is asked

What ever is given is(are) parameter(s) and what ever is asked is a return value. 


OK, Now coming back to my sons text book. I was horrified (for the first time and terrorized to read rest of the book) to see an example of a function like this.


Calculate the  area of the triangle where base and height measurements are given.



float area (float half, float base, float height)
{ cout << “\nTriangle ..”;
return (half* base*height);
}



We used to have jokes like a science teacher setting a history question paper. I wish  Computer science teacher sets a maths question paper.


I dont know how many of us had really seen this book. Please download a copy and send your feedback.
But more horror stuff is ahead.



2 comments:

  1. got stomachache bala..rolling on the floor...bala, send your son's book to ananda vikatan. they lost their touch and their jokes don't make me laugh anymore. i guess the author of the book might have been psychologically impacted when the gang of astronomers degraded Pluto from the status of a planet. He / she would have thought that when a planet is no more a planet, there is a good chance that a half will no more be the same half in future... btw, regarding the engg grads who don't know how to code functions...don't reject them in the interviews. they seem to have the DNA of the managers without even the need to go through the typical career of a s/w engg :)

    ReplyDelete
  2. Some of the comments in this article reminds me of an interview I had to conduct to pick a developer from a pool of "well trained" developers in a well established company I had worked for.
    A standard question I gave to each one of them by giving them control to my white board and markers
    "In simple terms explain me inheritance in object oriented programming"
    Believe me.. Not one candidate deviated from the path. Every person Every person gave a seemingly clear standard answer on the lines of Animal..cow..dog..bear..
    To everyone I asked again, "well.. understood. can you give me a practical IT example.. from any project you worked with. Any simple example is okay. Or you can write down some program snippets and show me "
    And believe me, these people had shown atleast 2 years of programming experience in their resumes.
    NOT ONE of them could go beyond the animal..cow..dog..bear story..
    They seemed to think and come back to the same example.!!!

    ReplyDelete