Wednesday, September 25, 2013

Who inspires you?

Many of us are inspired by role models around us, in person, in media, in history, men and women who lead by example. I remember an instance - a colleague of mine was asked about role models and he was selected because he mentioned his grandfather. Other colleagues who mentioned names like Mahatma Gandhi were rejected, because in the HR's mind, a role model has to be someone you personally know. I felt those were very strong opinions to make a judgement for employment

In the past, I've had several role models


  • My dad - for simplicity, integrity and courage to do the right thing and caring for others. Ability to network, empathize. Social causes and care for poor.
  • My mom - for her ability to manage so many things, manage the family, swiftness, love and extreme courage. Her ability to network
  • Mahatma Gandhi - For large traits of what I saw in my dad.
  • Don Knuth - For being so nice, smart and humble
  • Ex-leads - technical leads in my first job, software architects, distinguished engineers from whom I've learnt a lot. Learnt virtues of caring for people beyond the scope of work.
  • Relatives and friends - who've stood by thick and thin, good and bad times
Today I was inspired by our security guard. His simplicity, his dedication to work and sincerity inspired me. I write this blog and dedicate it to all those who inspired me. I think we don't need to look very far for inspiration, it is right around the corner, in my case right at my doorstep.

I hope all of us find many role models who inspire us to do the right thing for ourselves and the society we build together.



Thursday, September 19, 2013

The call for better reading/writing skills

I am sure you've faced it and done it to others - not read the entire email in totality or communication in full and missed parts of it. With the abundance of information comes the challenge for the new age of engineers to read and parse information completely. There is a challenge that people writing blog posts such as me, do a good job of delivering the information in manner that key points are not missed

Summary of the problem


  • Of late, I've seen people ask questions already answered in the email they are replying too
  • People chain emails expecting everybody to read things top to bottom
  • Most people reply on top of emails. Top Posting


I think the open source community solved this problem with rules and netiquettes, but most of us who are not aware of them - fail to see the importance of communicating clearly so as to get maximum retention benefits from the audience of the communication.

In my mind, here are the best practices



  • Make sure that the key information is not hidden in a paragraph, but upfront
  • Try to summarize, re-emphasize
  • Use best practices, netiquettes
  • Don't forward or reply to long chains, clearly snip out irrelevant content
  • Use smart subjects
  • Highlight important points


If you are on the receiving side



  • Spend some time on important emails, if required re-read
  • Try to limit the amount of emails you read - batch process, don't switch too often
  • Remember, email is official communication


Wednesday, September 18, 2013

A poor way to do sorting in an OO language (java)

Going back to Java after so many years is an interesting experience. I made the classic rookie mistake with implementation of a sorting library. All good programming practices tell you that manipulation methods on a collection should always be static and not bound to the class. To top it all, this was the first time I was using generics after spending some time reading about them :)

I had done things the other way around, almost as if I had implemented a stack with data. My ego was too big for me not to succeed with that technique. Here is an implementation of selection sort. Below is what I ended up implementing

/**
 *
 * @author balbir
 * @param 
 */
public class SelectionSort < Item extends Comparable > {
    private Item[] elements;
    SelectionSort(int N)
    {
        elements = (Item[]) new Comparable[N];    
    }

    public void sort()
    {
        int min;
        for (int i = 0; i < elements.length; i++)
        {
            min = i;
            for (int j = i+1; j < elements.length; j++)
            {
                if (elements[j].compareTo(elements[min]) < 0)
                    min = j;
            }
            Item tmp;
            tmp = elements[i];
            elements[i] = elements[min];
            elements[min] = tmp;
            
        }
    }
    
    public void dump()
    {
        for (int i = 0; i < elements.length; i++)
            System.out.print(elements[i] + " ");
        System.out.println();
    }
    
    public void load(Item a[])
    {
        for (int i = 0; i < elements.length; i++)
            elements[i] = a[i];
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Integer[] a = {1, 2, -1, 3, 0, 5, 7, 9, 4};
        SelectionSort s = new SelectionSort(a.length);
        s.load(a);
        s.dump();
        s.sort();
        s.dump();
    }
    
}


It is funny how I had to use a load class to get the data and call the sort method. What a bad decision, the reason I shared this post is just to show that with generics one can indeed mix classes and class templates. I for example mixed Integer and Comparable and the default implementation worked.