Sunday, April 22, 2012

About the GAP

Almost 20 days since I posted last. Was very busy interviewing the first set of people into my company Ardhika. Was looking for fresh graduates since I do not want to waste time with people who say they know "Springs" or "swings" etc. 


First I started with an objective of getting people with some Java knowledge and after seeing 10 got frustrated and became more positive in getting somebody with knowledge of some logic and teach them Java. Then I saw 

  • Almost all stumbled to write a function to add 2 numbers
  • Cannot write a Person class with firstName, lastName and age as attributes
  • Always start the class with a PSV main(). For those who dont know what that PSV is it is the short form of "public static void". Similarly the other trick is SOP stands for "System.out.println"

I start with a question to write the person class above. After they write I will ask them to support my code
Person p = new Person("Bala", "Sundarasamy", 41);


Except 3 most of them fumbled at this point. Remember most of these people were not from a good financial background. Yet they have paid from 20K to 50K on Java courses outside their curriculum. 


If they are 50% into writing a constructor with my help (I was also judging whether they listened to me and took my help) I would ask them to support my code


System.out.prinln(p); 


which should print "Bala Sundarasamy is 40 years old". This is where all of them except 1 got  caught completely by surprise. Most of them tried to roll their own print function in Person class.
Then i ask them whether they know anything by name "toString". 


To my surprise one guy who got 98% in SCJP immediately said he does not know. Should try if anyone with an OCJP will know. Hope Oracle would have made a difference!


As a person who respects my mother tongue I did the interview in Tamil.  Finally selected 3 and they will have to undergo learning (self) for 2 months before they can become productive. Hope my teaching skills are still intact!


Forget about writing class, I asked one of these candidates to count the vowels in a given string. For some reason he started with last character. Then I could immediately guess he had written mostly string reverse function in his academics and interviews. And he confirmed later that my guess was correct!


Why are these academicians not doing any justice to sons and daughters of farmers , electricians and other people who are financially not doing well by providing them a good education for the money that they are spending on us? 


The education system is completely crippled! And none of them respect the responsibility they have towards the society.


I am not sure most of lack the skills of teaching but definitely are irresponsible.


OK, How do you teach some one to reverse a string?



  1. String is an array of characters
  2. Go to the last element
  3. access one by one and add it to a new string - reduce the index of source string and increase the index of destination string in every iteration

How do we go to the end of string? I would say find the length of the string and length -1 is the index of the last character. This particular piece of information must get into the students head strongly. 


But this is how it is taught to people in higher secondary (C++).



char name[] = “Pascal”, reverse[7];
int i= 0;
while (name[i] != ‘\0’)
    i++;
reverse[i] = ‘\0’;
—i;
int j = 0;
while (i>= 0)
   reverse [i—] = name [j++];

Why cant they use the strlen() function? In fact it is discussed in the page before this.

Most of the C programs dealing with strings will make extensive use of the strlen() function. But this book never used it! 



And here is another piece of GEM!


This class is called "strings" but deals with only one string.



class strings
{
char s[10];
public :
strings()
{
s[0] = ‘\0’;
}
strings(char *c)
{
strcpy(s,c);
}
char * operator+(strings x1)
{
char *temp;
strcpy(temp,s);
strcat(temp,x1.s);
return temp;
}
};

Look at the + operator overload.

I thought it should return an object of type "strings" but return a char*.  There is no memory allocated. I think the authors did not do that because of their peculiar aversion towards strlen() function. Had they used another "strings" object to hold the result they would have got at least 10 bytes and their main() would have worked.


But they have got a main method like this to test this class and + operator.


void main()
{
clrscr();
strings s1(“test”),s2(“ run\0”);
char *concatstr ;
concatstr = s1 + s2;
cout << “\nConcatenated string ...”
<< concatstr;
getch();



After going through the book several times I am sure of one thing I dont have to teach these guys the clrscr() and getch() after they complete engineering and come for a job. 


Imagine what would have happened if some author of a school text book misrepresented a fact about any of the political leaders or skipped a poem or a lesson written by them!



Sunday, April 1, 2012

The Dangerous Combo

My friend Sathiya gave a comment for the previous blog that the authors of the C++ textbook thought  half will not be half anymore! But they have redefined some other basic stuff also.


Here is how they convert feet into inches :



 void main()
{
int feet;
const int inch_conversion = 12;
clrscr();
cout << “\nEnter feet …”;
cin >> feet;
cout << “\nConverted to inches …”
<< feet * inch_conversion;
}

and some 30 pages later  the whole world changed upside down (i.e pluto is not a planet anymore, half is not half anymore and 1 inch became 12 feet)

inline float convert_feet(int x)
{
return x * 12;
}

void main()
{
clrscr();
int inches = 45;
cout << convert_feet(inches);
getch();
}

Guess convert_feet function converts inches to feet or feet to inches?
People are so bothered about clrscr() and getch() but not about some basic stuff!
What they say is, "just get the syntax of inline function dumbos! We are not teaching mathematics here!"

I see that what they need to concentrate on first is the naming convention and proper example. I saw a video in youtube where an Instructor is teaching the basics of OOP 
Encapsulation, Inheritance, polymorphism and abstraction all with a beautiful example in 10 minutes. The example is a class :

class C {
int i;
char ch;

int get() { ...}
void set() {...}
}

And mind you our students are still seeing this video. Coming back to our text book it defines polymorphism like this.

The ability of an object to respond differently to different messages is called as polymorphism.


If you copy-paste this statement in Google and you will get only one result (in fact 2 but both point to the same) which is our famous text book. They have defined polymorphism uniquely.

World over we scream that it is a good practice to name the classes after nouns and methods after verbs and the class name to a greater extent Singular. But this book follows consistently class names like, add, subtract and strings (which represent only one string anyway) and method names like operation, addition and subtraction etc. 

The above convert_feet() has a formal parameter name "x". Had it been "inches" it might sort of give an indication. 

But who is bothered?

We are happy to announce and get inches in the news papers and magazines saying we work close to the academics and government and probably telling customers (when we are after multi-million dollar deals) that we have a good supply of engineers.

But what is that we are really doing for the society and country? Or even our own pool of future resources? 

Do we really think that we can still be customer focussed and deliver a quality solution to the customer? Or should we take this as an opportunity for winning a endless maintenance contract for a system full of bad code?

What is the dangerous combo here?

The academics and OOP! 

They are sitting out there ignored by all of us and spreading all kinds of ideas about OOP which becomes a major obstacle in doing a technical induction training. 

Either we have to train and handhold them like our own training department (if we are really doing that!) or I have another futuristic idea and share it in the next blog..