Saturday, July 28, 2012

The thing called "DESIGN" !

I am greatly confused with this term called "Design".  Recently I had to develop a workflow engine in the quickest possible time. I have a team of 3 people and for 2 of them this is the first software project in their life. 


I started to write Java classes representing the flow model, nodes (tasks) in the flow, the attributes of the model and transition. Then I wrote methods to execute transitions. All in all under 10 classes with 3 to 4 methods excluding the setters and getters.


It took nearly 3 hours to explain them the code and I asked them to write the Hibernate mapping files, DAOs & Services for persisting the model data and for the execution API. Things fell in  place nice and smooth.


The whole thing got completed in 3 weeks.


How much time this could have taken in so called Process Oriented consulting companies?


I would have drawn UML (class diagram and sequence diagram) first as part of my design process. This could have easily taken 2 weeks. Then the developers need to have knowledge in UML to read and understand the diagrams. I could have asked the developers to first write code for the classes. That would have taken another 2 weeks easily. Then comes the persistence and service layer classes.


For me clearly the use of UML here would delay things. Consciously I have avoided this situation by not drawing the UML diagrams. Because I have never seen a case where some one need to draw UML diagrams first before coding.


So, what is that I have seen in consulting companies where there is time allocated as design phase to draw the UML diagrams?


People who stopped coding long ago (5+ years) come out with Class diagrams ( a.k.a High Level Design). People who stopped coding recently(3+ years) start drawing sequence diagrams using these classes. The design tools ( or at least Rational) have 2 types of class diagrams called logical class diagrams and design class diagrams. These sequence diagrams would use both of these interchangeably because none of the logical or design class diagrams would be complete and this happens because (Yes! you guessed it) the designer is not current in coding.


Now, the developers are left free to implement them in the way they want. Introducing instance variables for stateless classes and adding more methods etc.


After some time the design and code mean 2 different things!


But I was taken aback first when i heard the concept of Class diagrams representing HLD and sequence diagrams in LLD. This is completely absurd because sequence diagrams are the unit test cases for your class diagrams and I will not just take Class diagrams from "a" designer unless he draws a complete sequence diagram and prove that the classes have sufficient methods to solve the case. 


People need to clearly understand one thing people who don't know the classes, methods, constructors etc, would not understand a UML diagram and people who understand this don't need a UML diagram. They better can see the code. 


Another fact is that a designer who can clearly think of these can straight away write the code (or at least stubs or interfaces) and leave the rest to the developers. 


Customers wont understand this and developers can understand the code better. More over the developers will be constrained to write the code with in the boundaries set by the designer.


And finally you dont have 2 different work products.


Now, if you go closer and see what type of architecture translates into the design of various systems :

  • There will be classes that are called DTOs. These things have nothing but default constructor and public getters and setters
  • There will be DAOs for CRUD functionality and a service layer which acts like a proxy or some times transaction handler
  • The best improvisation that is done most of the times when the customer (who has a decent developer in their team) complains that the whole code is procedural and not OOP is making an empty base DTO and make all DTOs inheriting from that!

If these are the principles behind the architecture do we really need UML? If a developer works on 2 projects like this he can start writing the code straight away.


Developers and designers work on measurements on two orthogonal axis. Developers top - down or Y axis by length of code and designers left to right on X axis by the length of the sequence diagram.


Developers increase the lines of code by calling innumerable amount of setters. Designers lengthen the sequence diagram by another mile by inserting HTTP objects such as Request, session etc. By showing how the data is stored and retrieved with them.


It leads to every one wasting time on unwanted things and produce non maintainable artifacts. 


Avoid all these and understand that "Code is Design"! 





Thursday, July 19, 2012

I am back!

Again a long break! A hectic and frustrating period. Hectic because i had to find a seat for my son in an engineering college! And a frustrating period in my business!


So, let me talk about the business! In a software consulting and development business there are 2 entities. One (Sales) who gets the customers and tries to convince them that he can get the software built. The other (execution) who actually gets things done that is software built.  The second one should understand the customers business and knows to implement it in software. 


There are execution guys owning and running the company and the sales guys are employed. And there are people who have lot of contacts owning the companies but slightly weak in the are of  getting the software done. Later is the case in a couple of small companies i tried to partner with and bid for projects during this period.


That lead to a lot of slogging and sweat on my part because unfortunately i knew how to satisfy their customers. one was a fruitful and good experience which could lead to a long time association and other one was a complete disaster. And we dropped that opportunity because of lack of transparency on the partner side.


And one of my long cherished desire got fulfilled when I rolled out my own workflow server as part of the project. I have been thinking about doing this for the past 16 years! That was a win!


Now, I have some time to breath and more than this blog I want to continue contributing more towards my other blog (Java in Tamil). Should start blogging during this week end.


So, I have made the following resolutions

  • One new post per week on this blog
  • Two new posts per week on the Tamil blog
  • Be careful in choosing the partners! And be more transparent and upfront with them and also make them do the same to me
  • Find an answer for the problem : Contacts Vs Execution

Let us see how these things work out!









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

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.



Wednesday, March 21, 2012

Why most of the projects rot and smell?

I did not get any negative comments on yesterday's blog. In fact people were sounding relieved. We go to colleges to recruit in larger numbers and it affects the over all education system. But we dont realize that it affects our business also. 
Over the years we have perfected the process of campus recruitment. Or that is what we think. This is similar to any software development process which we think we improve continuously.
We are going to campuses for a very long time now. We learnt a lot and perfected an assembly line process. 
In the beginning when we were with less funds, we were getting the recruits sit in the front of the bicycle we were riding. Like a Girl friend or lover and the relationship was so passionate.
Later when we could afford a little bit more we had a wife in pillion of our scooter, a kid in the front and a smaller kid between us and our wife. There was love, duty and some amount of accommodating ability that we showed them.
Later we were driving a car with few more people and somebody probably who is sitting in the rear kicked our back.
The family grew and we know it all and sudden explosion of growth we are driving huge garbage collection trucks which go around streets with plenty of garbage bins. Now we have our own uniformed people to come with us. We are equipped with machinery like fork lifts and pulverizers.
We come back with a big monolithic chunk of ungraded garbage.
And in the material we supply mixing this to the extent of 40% to 50% gave us a gross margin of more than 30%. 
Who cares?
Our projects rot and smell!
Yes, we need more people to sustain the business but how do we know that we are sourcing it correctly?
At most we donate books, conduct some basic training programs, sponsor and participate at symposiums and give guest lectures. 
Have we ever tried to know or improve what is being taught to all these people?
If we do it we will not be driving garbage trucks but cruising with people in the clouds.
We even shy away from putting good people in to our own quality and training departments, I think I am asking for too much!
It is time to give things back now! Why cant we use a minor portion of the calculated and affordable bench strength to teach some good things to all these poor boys and girls at colleges?
We have spilt colleges into tiers and go for a Guinness record with tier 1. But remember the 50th person there is not going to be anyway superior to a 5th rank holder in a tier 3 college where none of us go for recruitment.
It is not only tiers we also have classifications like software branches (CSc & IT), circuit branches (ECE & EEE) machinery branches (Mech, Production) and we dont even leave civil.
It is not only that our children are not going to get a good school education the future society is going to import civil and mechanical engineers from foreign countries paying a premium.
We need to have a better system in place at least now to safeguard future and our own business.  
Our selfishness must be driving us towards this!



Tuesday, March 20, 2012

Why this blog?

I wanted to start blogging a couple of years ago due to some reasons. Over the past 2 years the reasons grew in number but never had the initiative to start writing. Now it has come to a stage where i cannot hold myself anymore.


Last week, I saw an article in "The Hindu" about most of the first year students in engineering colleges in Tamilnadu failed to clear the fundamentals of Computing paper. As reasons the writer (or who ever expressed their views) quoted 

  • Many students studied in Tamil (local language) medium where as English is the medium of instruction in Engineering colleges
  • Students prepared using a question bank of programs. But questions were not from the bank

In the website of "The Hindu" a dozen of people submitted their comments on the article. And in a nutshell these were the views of the readers

  • Why so many people join engineering colleges with out understanding whether it is manageable for them
  • I did not study Electronics in my school but i did well in my college
  • These things are not excuses

etc.


I also posted a comment but it could not get through moderation I suppose! My comment was on the lines of "Why are they having a written examination where people have to write programs? 
If someone had studied Computer Science in the school final (higher secondary) I can guarantee that they will not do well in Programming assuming college education is better"


Definitely this was not something expected as a comment. The problem is that this is cryptic and if understood cynical. So, I did not worry about not getting this reach people.


Why people are flocking to Engineering colleges today?
Is that because there are thousands of engineering colleges all over India? (There are 500+ engineering colleges in Tamilnadu alone)


Colleges are entering guinness book of world records for getting 600+ candidates selected into a single company!


Job Guarantee is what is driving all these people!


Our dream software companies never looked at Electronics graduates back in 1992 in my final year(College of Engineering Guindy, Anna University). The same companies are recruiting 500+ even if the total of Computer Science and Information technology branches pit together will not reach 150. In reality they recruit even Cvil and Mechanical engineering students (for testing or some other non programming tasks).


This has a cascading (bad) effect in our society.  In the last 15 years we have stopped talented engineers doing masters and PhD and go back to teaching in Engineering colleges.


Now, we are recruiting almost all the people out of engineering colleges (for guinness record) and made a lot of people start engineering colleges. Almost 6 years back itself the total number of seats in engineering colleges were enough to take all people passed out of Higher Secondary with minimal qualification. So, nobody goes to study science subjects these days. So, no good teachers in the school also.


Now itself i have seen some engineering graduates teach computer subjects in the schools.


Future is definitely not going to be good for students and the industry!


Hope i have given a message here.


I started this blog with title "Why this blog?" and I am ending this with a famous question


Why this kolaveri?