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..

1 comment:

  1. Very relevant post, Sir. I personally could not get head or tail of the programs I learned during my uni days... Programming can be easy - it just has to be taught in a logical way. But as you said, who cares?

    ReplyDelete