Monthly Archives: December 2013

To take or not to take a programmer lead or manager role

Published December 4, 2013 1:02 pm

In the last post, I tried to go over natural traits of a programmer and see whether one has natural inclination to be a programmer? As a programmer, you come at a crossroad – typically in 1-5 years – where you have to decide whether you want to lead a team? It exposes itself as an opportunity or you come across it when thinking about your career growth. In my case, it came as an opportunity within 3rd year of the career as programmer.

It is human to feel uncomfortable with the change at the onset. I did not know much theory about change mgmt. then. Later, I had come across theory about how people respond to change. Closest picture I could find on net about that is here and here. Your response to the expected change might be inline with the curve in the picture. That is ok but there is more to this.

There are 3 parties involved when you take up lead role – you, work and team. As long as you work as a programmer (individual contributor aka IC), there are only two parties involved – you and work. This change is key to note. There was so much to learn when I boarded my first job. My key focus at that time was to grasp, learn at exponential rate. In a way, focus is so much on you and what you produce; your excellence. The other parameter – team – brings team deliverables, team performance and career mgmt. to name a few items. Like it or not – they are equally important if not more – in your role as lead. (There are many titles that are used for this – like dev lead, project manager, test lead, qa lead. I will keep it as lead in the post.). It is good to come to terms with this. This will impact how much time (at the least in the short term) you can spend programming/researching yourself. Typically, you get to spend good 50% time or more with other items – to begin with.

Lead role typically comes with career growth though it may not always be the case. There are companies where there is a parallel career path for IC and manager. That is there is no need to be a lead – only for growth. Also in this role, supporting people through their career growth generates intangible job satisfaction. It is very key to know your intention. That is whether you are interested in the lead role for career growth or supporting people or both. If for career growth only or mostly, it may not work well. It will be hard to grow as a manager without being genuinely interested in people, and you may finding it taxing. Well, we all see during our career – good managers and bad managers. How come the bad manager could grow so much in that case? You are right. Let me put it other way – you might not make a great manager although you could still grow based on other parameters like – taking scaled up responsibility and deliverables. In nutshell, it will always help – to have genuine interest in the growth of the people – as manager. It may not stop you from taking a manager role.

First level manager are better accepted as techno managers. Are you at a stage where you have something to impart to the fellow team members? Some of these questions might help know that objectively?

  1. Do you ace your deliverables in the project?
  2. Are you considered a go to person for some of the component(s) in the project?
  3. Have you successfully on-boarded/mentored new joiners in the project?
  4. Do you produce code as per the standards of the group – if not help improve it?
  5. Do you debug difficult technical bugs and issues for the project?
  6. Have you handled external communications (technical or otherwise) sometimes?
  7. Have you negotiated your schedule/deliverables with your manager?
  8. Have you debated technical designs/issues with fellow team members?

Some of these question will help answer objectively whether your team can look up to you – to learn & lead and whether you have basic skills to lead a team. I am not going through the laundry list of skills here to avoid going by the book. Your organization might have listed the management skills formally and it won’t harm to skim through them.

If these parameters are aligned – that is 1) you are ok juggling – you, work and team – priorities and its impact on your daily working pattern 2) you are interested in people n their career 3) you ace your art as IC and have basic skills required to be first level manager, it won’t harm to take your first plunge into leading a group of programmers. Even if you are not be able to make an long term choice – to take IC vs lead track now, experiences from lead role will help hone up new skills that compliment technical skills for your career growth. For example: it helps – to be a better communicator, to be able to influence fellow team members, have empathy and to be little more team-social – as IC.

If you have made a choice to take up lead role, congratulations in your new role and best wishes! After few more years into your lead role, you may face more choices. For example: shall I go back to an IC role, is moving between IC and lead roles ok, Shall I take up M2 role, Can I take up programmer role as life time career path? Let’s pick up one of these in the next post.

Using WinJS.Binding.List to update the list view

Published December 3, 2013 1:06 pm

WinJS.UI.ListView is the most used control in WinJS library. At the beginning, you typically start with static List views. In such List Views, data does not change after it is bound. You may have to sort or group data which can be achieved using createSorted or createGrouped methods on List. You can order the items, group the items, and order the groups using these methods. If you follow some of the msdn listview samples, it is sort of clear. (Note: not all samples needs to be followed to get hang of list view. Some of them like custom data source, incremental loading are advanced scenarios).

When you working with dynamic data, list view updates as user interacts with the list view. Examples:

  1. User can right click a item, and delete it using contextual app bar command.
  2. User clicks/taps an item. The item is either removed or updated.

List view elements sort order and grouping needs to be maintained after the item change or list changes. In this post, let’s look into (2). I will try to cover (1) in another post. To go over this, let’s take a simple problem of displaying list of todo tasks.

  1. The tasks should be displayed in two  groups – ‘todo’ and ‘done’ groups.
  2. When a task is clicked or tapped in the todo group – it is moved to ‘done’ group.
  3. ‘done’ group should maintain only the latest 5 done tasks. oldest task gets off the list when list grows beyond 5 tasks.

my-tasks-1With this, Let’s look at the HTML

<div id="todoListView" data-win-control="WinJS.UI.ListView"
    data-win-bind="winControl.itemDataSource: items.dataSource; winControl.groupDataSource: items.groups.dataSource"
    data-win-options="{
      itemTemplate: select('#todoItemTemplate'),
      groupHeaderTemplate: select('#groupHeaderTemplate'),
      selectionMode: 'none', swipeBehavior: 'none', tapBehavior: 'invokeOnly' }">
</div>
  1. list should have tapBehavior set to invokeOnly to enable click/tap.
  2. itemTemplate and groupHeaderTemplate are set which is kind of obvious.
  3. this snippet binds itemDataSource and groupDataSource in html. If you don’t have view model (MVVM) separate in your code, you may set it in the .js file.

Let’s look at the sample data.

var data = [
    { status: 'todo', title: 'wake up' },
    { status: 'todo', title: 'brush your teeth' },
    { status: 'todo', title: 'take bath' },
    { status: 'todo', title: 'do yoga' },
    { status: 'todo', title: 'take breakfast' },
    { status: 'todo', title: 'check email' },
    { status: 'todo', title: 'check facebook' },
    { status: 'todo', title: 'check stackoverflow forum' },
];

We will sort the list using the sort key <status, finishTime>. finishTime will be added whenever user taps the item. todo status is sorted before done status. finishTime is sorted in descending order. This way – all done items are order towards end of the list. Further, If any item is to be dropped, it is at the end of the list.

 

    function compareStatus(t1, t2)
    {
        if (t1 == t2)
            return 0;
        else if (t1 == 'todo')
            return -1;
        else
            return 1;
    }

    function compareFinishTime(d1, d2)
    {
        if (d1 == undefined && d2 == undefined)
            return 0;
        // treat unfinished task ahead in sort order
        else if (d1 == undefined)
            return -1;
        else if (d2 == undefined)
            return 1;
        else
        {
            var t1 = d1.getTime(), t2 = d2.getTime();
            // treat recently finished task ahead in sort order
            if (t1 > t2)
                return -1;
            else
                return 1;
        }
    }

    var sortedList = list.createSorted(function compare(i1, i2)
    {
        var c1 = compareStatus(i1.status, i2.status);
        if (c1 != 0)
            return c1;
        var c2 = compareFinishTime(i1.finishTime, i2.finishTime);
        return c2;
    });

Further, we use createGrouped to group the sorted items and order the groups.

    this.items = sortedList.createGrouped(function groupKey(item)
    {
        return item.status;
    },
    function groupData(item)
    {
        return { title: item.status };
    }, 
    function groupSorter(g1, g2)
    {
        // keep todo items group b4 'done' items group
        if (g1 == g2)
            return 0;
        else if (g1 == 'todo')
            return -1;
        else 
            return 1;
    });

Now, to move the item from ‘todo’ group to ‘done’ group – we can change the item in the iteminvoked handler and notify the list for item mutation using notifyMutated method. Once notified, list sorted and grouped projection will update themselves. It will reflect in the bound list view.

 
registerItemInvokedHandler: function registerItemInvokedHandler()
{
    function oniteminvoked(event)
    {
        var index = event.detail.itemIndex;
        var item = this.viewModel.items.getAt(index);
        // click on 'done' tasks should be noop. 
        if (item.status == 'done')
            return;
        item.status = 'done';
        item.finishTime = new Date();
        this.viewModel.items.notifyMutated(index);
        // schedule removal for later using setImmediate
        WinJS.Promise.timeout().then(removeIfReqd.bind(this));
    }

    function removeIfReqd()
    {
        var count = 0;
        var items = this.viewModel.items;
        for (var i = items.length; i > 0; i--)
        {
            var item = items.getAt(i - 1);
            if (item.status == 'todo')
                break;
            count++;
        }

        // remove only if more than 5 'done' items
        if (count > 5)
            items.splice(items.length - 1, 1);
    }

    todoListView.addEventListener('iteminvoked', oniteminvoked.bind(this));
},

my-tasks-3* Note the code above references items from the viewModel. That needs to be modified to reference items as per your code.

This way – we saw in this post – how createSorted, createGrouped along with notifyMutated – can be used to build a dynamic list view.

To be or not to be a programmer?

Published December 2, 2013 3:44 pm

Do you have appetite to be a programmer? Do you relish programming? Can programming be a life time career for you? These might be some of the questions –  a programmer may ask himself at different stages in his career. There is no definitive formula – I have seen – to get a yes/no answer. I am also somewhere in the mix, and can share some of my experience.

When I was graduating from the college in comp sc., I got first introduction to programming. As part of the first semester to learn Pascal, I got the first kick for the programming, and found like minded classmates; among us we gave competition and positive pressure to keep leaping and stay one semester ahead. We were always one semester ahead for the programming courses. That time – I did not ask myself – whether I have appetite for programming or whether I relish programming – but I simply found my appetite for it and relished it. Looking back, I can see few things that stand out if one has appetite for programming:

  1. Getting the output after few-hours of hard work – putting the code – gives immense satisfaction.
  2. You are impatient to put all details on paper or a document. You itch to code it and see it working. You would draw/put a rough sketch/skeleton pseudo code and then, get to code. Iteratively – add functionality and see it working.
  3. You have more inclination to mathematical problems than theoretical subjects like History. Because you find it intuitive to score well in logical subjects. Once the concept is learnt, that is it; no mugging required.
  4. You itch to learn new languages. but time constraints keep you away if at all. You definitively take up assignments outside the course – out of your interest.
  5. You wish if you knew all apis by heart – that way you can code fast. You learn the shortcuts of the code editors. You learn typing if you don’t know already;)
  6. You care for good design but you are averse to any process overheads that let you not produce code. You certainly don’t gel well with process-first managers.
  7. You take bugs in code personally and constantly challenge yourself to produce bug free code. I have heard Sachin saying once that he thinks over after each match – the reason he got out. You would think every time you fix a bug – what would have saved that bug.
  8. Code is your art. You strive to get better at it. You are naturally inclined to pick good treats from well written code. You hate badly written code and want to eliminate it. You always carry your code with you on your external disk, pen drive, cd etc. unless the IP rights prohibit you.
  9. You strive to get working code daily if not every hour. You can sit at stretch for 4-10hrs daily coding.
  10. You rewrite your own code until it matches your criterion of quality.
  11. You like being in code than in ppts.

If you see some of these traits, it is likely you have natural flair for being a programmer. It is very likely that you have already embarked on it since it kind of comes natural. The real questions start popping years later when 1) one is faced first time with the choice of taking up lead/manager role and later, when 2) he/she needs to decide whether this can be a career choice for life time. (1) is easier than (2). Let’s catch up on this in the next post.