Archive for the ‘productivity’ Category

Getting Yourself Unstuck When Programming

Monday, July 17th, 2017

Everyone who has ever coded anything significant  (and probably everyone who has ever done anything that requires creativity) will recognise the problem of getting stuck. Most of the time it is caused by lack of information or confidence to move forward. Over time I’ve identified a number of reasons I get stuck and also strategies to deal with this.

Perceived Dependencies

In larger systems, components often have to interact. If none of these components are properly defined or all need changes, it can be hard to get started.
Strategy: Fake a little, build a little.
It’s tempting to start things from the beginning and just write the code sequentially, however if things are not entirely clear it can work very well to start at a very very high level.
I usually just outline everything in 3 to four steps, each being a commented line. For example if I need to classify emails into categories, I might write something like:

// get e-mails
// get defined categories
// classify e-mails

Then write each step as code. This is the time you will need to start thinking about how data is passed around. Whether you will need objects or just lists of strings, etc.

// get e-mails
emails = get_emails()
// get defined categories
categories = get_categories()
// classify e-mails
classifier = new Classifier(categories)
for email in emails:
    scores = classifier.get_score(email)
    category = get_top_category(scores)
    print email.title, category

To test these assumptions you will need to actually implement the functions/components you’ve used. However, key to this strategy is to now fake these functions/components as much as possible.
e.g. I may implement get_top_category as:

def get_top_category(scores):
    return scores.keys()[0]

The reason to do this is not because I don’t know yet how to implement this, but because I don’t want to get stuck in details. (e.g. what happens if there is a tie, what if all are zero, etc etc) Things become so much easier when you have an end-to-end solution that just compiles.

Can’t wrap your head around it

You all know this feeling, but the cause is less clear. Ill defined tasks,  generic approaches,  feeling tired,  they all can lead to this.
Strategy: Second Pair of Eyes
Not everything needs to be solved on your own. If you are not clear on the ‘what’, just talk to a coworker, manager or customer. If you are not clear on the ‘how’ just start explaining to a coworker why you can’t move forward on this.
A very important part of this strategy is the need to explain and define your problem. Even the act of just explaining it may resolve the issue. In that case it’s called Rubber duck debugging: the act of explaining your problem to a rubber duck.


This is probably the biggest show stopper:  as soon as you are aware that there are multiple options with various tradeoffs, it’s hard to proceed.   I’ve seen bad programmers finish things quicker, just because they were happy with any solution that worked, in their universe there were no trade-offs to be weighed.
Strategy: Writing
If choice and tradeoffs are involved, you need to start writing. Just create a document with bullet lists of:

  • Everything that is already given (e.g. API urls, relevant documentation)
  • Requirements
  • Important conditions (e.g. needs to work when device is offline)
  • Potential issues (e.g. there may be too many items to fetch in a single API request)

Then for each of them come up with at least two approaches. Then for each of them also add potential advantages and downsides. And then again for each downside, figure out how to solve it.
For me this usually becomes a nested list of four or five levels.

One of the big advantages is that you can leave this for the next day to refine, without having to start all over again in your mind. Furthermore, you can easily refine this into documentation after the decisions are made.


The idea of heaving to spend days to do some boring, semi-repeatable task that could have been avoided when better choices have been made in the past  can certainly demotivate you.
Strategy 1: Embrace it
Sometimes you’ve got plenty of energy, but can’t really move forward on an issue (e.g. due to one of the reasons mentioned above) this is the perfect time to do this boring task you’ve been putting off. It is 100% clear and every minute you spend on it will actually move you forward.
Strategy 2: Make it interesting
Boring things are also often the things that are easy to automate. This might be the right time to learn more about:

  • advanced find/replace features in your IDE
  • find/grep/sed on the commandline
  • UI automation

Strategy 3: Delegate
What is boring to you, may be a nice task for someone else to learn a new skill. e.g. writing UI tests might be boring, but it can be a valuable and marketable skill for your intern.


Lots of people get stuck on finding and fixing bugs.  But remember, in debugging there is always a next step to take.
Strategy: Identify and check your assumptions
At the root of every bug is a bad assumption. This can be an assumption on what your code will do, the contents of a variable or the correctness of an external dependency. Debugging is just identifying your assumptions,
I’ll write a follow up post on debugging strategies soon.

Idea Overload

Thursday, February 10th, 2011

You’ve got so many ideas in your head that you just don’t know where to get started. As a result, you start procrastinating on stuff you do feel passionate about. At the same time, you’ve got enough energy and are motivated to get stuff done.  It’s a bit contradictory state of mind, that happens to me once in a while.

The problem is anxiety to commit to one project and  even more so: leave all those other things alone.  I believe the key to overcome this problem is to start on anything.  In the end it does matter much more that you’ve made progress and added value than it matters which choice you make.

Of course, that’s easier said than done. ‘Pick anything’  is still a choice and choices are hard. Therefore I use a very simple solution:  pick the easiest task that still adds value.   In the end you probably will have to do all those tasks anyway, so why not start with the easiest one?    Especially  in programming,  getting anything done, will give you more context to solve the next task.  Tasks that may have seemed daunting at first, become easier and better defined when the system around it takes shape.

Why Time Management Methods Work

Monday, November 22nd, 2010

I strongly believe that energy levels, focus and productivity are related and come in closely related cycles. I’ve always had weeks I can get done great amounts of work, followed by weeks of procrastination and inactivity.

Now at some point in this cycle, energy levels start to rise, but you are still in the habbit of low output. This will make you you feel guilty of not outputing, while your mind does want to. You are starting to imagine all the work you want to get done and does not seem to come along at all.  This is where time management methods come in. The promise of beating procrastination and the overwhelmed feelings. So you try to follow them and it helps you get your thought in order and get more work done. Up till the point that everything is going well,  you’re on a roll. If you are like me, you have already abandoned the time management method, because it feels more like a chore and everything is moving along without it.

The Productivity Cycle

My feeling is that time management does not actually help you that much,  you just try it at the time that your productivity is already bound to rise up the cycle again.   The real problem comes when your energy levels are dropping again.  First you overcome it by moving to simpler tasks, but slowly procrastination creeps in.  The problem is, you don’t notice it, until it’s to late. At which point you don’t feel like doing much at all, most certainly not some complicated time management method.

I do believe that you can influence the whole cycle, but it’s way outside the scope of time management and has everything to do with your general well-being and the habits that influence it.

Waves of Productivity

Wednesday, November 10th, 2010

Another reality is that energy and productivity come in waves.  Although those hyper-productive days feel great,  there is no substitute for steady output if you really want to move forward.  However, I do suspect that those hyper-productive days are probably also the cause of the low-energy weeks that will follow.    It are these low-energy weeks that are plagued with  procrastination (in all sorts and shapes).

I wrote about procrastination before, this time I’ll tell you what I found out doesn’t work:

“I’ll do it tonight” – Although it seems a good idea (and feels good at the time) to fix a time to do a task in the near future, it’s actually the worst idea and it is the essence of procrastination:  postponing things you could and should do right now.
There is an exception:  urgent tasks that come in while you are already really actively working on another task. However, make sure that you commit to it, by telling the other party as well that you WILL do it today.

Other times I try to trick myself in doing something: I tell myself I will do project A after I’ve finished (hard) project B, because B is more important. However, instead of speeding up B, this will usually result in feeling very busy and besides B still moving forward slowly, nothing happens on A either.  So:   if you are not really actively working on B RIGHT NOW, there is no reason not to work on A as well. There is just no way that you are dedicating all your effective time to that single important project, unless you are really close to a deadline.

Todo lists : Do and Don’t

Friday, October 22nd, 2010

Every time I’m unhappy about my progress I resort to Todo lists. Basically there are two types:  personal  and per-project.  Often a per-project todo list is implemented as a bug or issue tracking system.   These are very useful to keep everyone on the same page and not forget about things that do need to happen.  There is not a single reason why you should be using some sort of system to keep track of the future of your project.

The personal todo list is another thing (Gmail has a very nice and easy to edit one. )   Although they seem essential for a task-oriented approach to time-management,  I found there are many mistakes you can make.

The first and most important one is to let them grow:  You start enthusiastically with the first day, write down your tasks for that day and complete them.  However, not all days work out as well,  so  you will not always complete your tasks.  And here comes the danger of a todo list:  you tend to put the tasks you did not complete onto the next day.  So after a while your list gets full of tasks that you keep shifting forward.

The other danger is to put tasks on it that are not really tasks.  E.g.  ‘finish project X’.    That’s not something you can do now ‘right now’.  It’s something that has an undefined start, duration and ending. No wonder that it’s impossible to cross anything off for days. And nothing makes you feel worse than having a todo list and not crossing anything off.

The final problem is  adding tasks that are not for  today.  Often you have stuff that you need to do that feels convenient to put on your todo list. However,  if you are like me, you have a lot of these ideas and after a while it becomes more like an e-mail inbox up till the point that it seems impossible to finish everything.

So, learning from these mistakes I have decided that the best solution is to keep the Todo Today on paper and make a new one every morning. Furthermore the unfinished tasks from yesterday can not be at the top of your new day. Having it on paper will  encourage to not just re-edit yesterday’s list.


Thursday, October 21st, 2010

Just as I’m busy improving my time management skills I came across  a nice book that touches a lot of the subjects I wrote about (and plan to write about n the near future). An interesting thing I got out of it is the use of rituals to get focused.   As I usually don’t have a problem staying focused once I really get started. So I will definitely try to incorporate that in my life.

The book has a free (and hassle free) PDF version as well, so I highly recommend it as well as the blog I found it on:

Being Busy

Wednesday, October 20th, 2010

I have seen many other programmers with this behaviour and I do it to:  making yourself busy.  I’m sure you will recognize one or more of these:

  • Checking your e-mail more often than you get important new mail
  • Visiting news sites more than once or twice a day
  • Refreshing Adsense stats more often than they update
  • Twitter (It’s almost unavoidable to check the updates frequently)
  • Going through a fixed set of websites without really paying attention to the content (just checking if there are any updates)
  • Watching a news channel on tv, more than 10 minutes

All of this comes down to two thing:  feeling busy  and the need for something ‘new’.  You can tell yourself that these are things that do need to happen, which makes it much harder to stop doing them that often.  Furthermore,  if you stop doing one of them it is just replaced by some other time waster.

One thing I’ve done to counter part of this behaviour is:   switch of all notifications.  Beepings, blinking windows, etc. make it almost impossible not to check stuff way too often.

The other thing I am trying to do, is to consider the alternatives: What could I be doing instead?   To force myself to be more aware of this, I decided to leave the computer immediately when I find myself clicking back and forth.  Now there is time to evaluate:

Why am I doing this?
If it’s because I don’t want to do a certain task, what is holding me back?   If there is not enough information: go get it.  If you don’t know the solution:  sit down (away from the screen) and think about it.  The Pomodoro Technique I wrote about can help some times to commit to actually doing the task. Especially regarding sitting down to think about the task (with 100% focus) as part of the task itself might make a difference to you as well.

Can I do something else that is at least more useful?
If you don’t have the energy to work on the task at hand, maybe there is something else you do feel like.  Getting done anything is better than failing to do anything while trying to do the most important task.  I especially suggest:

  • Study something that will give you some inspiration (maybe some development / time management / marketing techniques)
  • Writing a blog post (Even if I don’t feel like coding anything at all, this often works)
  • Walk the dog ( It needs to happen some time, so better when you are not in the middle of being productive)

Can I do something more fun?
If things really aren’t going (you know those days) consider if there is anything more fun to do.  It might be better to just take the day of and really do something fun.  (Ok, I know… this isn’t an option for most with a regular job)

If all else fails, even staring out of the window might be a better spending of your time.

Disclaimer:  I haven’t really put all of this into practice yet, so more will probably follow.

Getting Things Done: The Pomodoro Way

Sunday, October 17th, 2010

A few days ago I wrote about procrastination and by coincidence I came across an article about changing your working method to embrace the interruptions, instead of trying to find long stretches of concentration (‘the zone’). It is a nice read, however, more importantly in the comment section I came across something that really appealed to me: The Pomodoro Technique.   I had seen it before, but it didn’t jump out to me at that time.

The basic idea is:  work for 25 minutes on a single task, with a timer ticking back the time left  and then take a break. This is augmented by a few other important steps, such as: noting down your distractions, evaluate them only after the 25 minutes are up and crossing of the completed intervals per task.

As I don’t have a proper timer yet, I looked for a software one, that works under Ubuntu as well  and came across:  Focus Booster.   It makes the ticking sound and also very nicely automatically starts your 5 minute break timer after time is up.

I just started using it, so I’ve only done a few of these ‘Pomodoro’ intervals, but I feel very confident that this will actually work as it makes you very aware of the distractions you need to avoid/delay  and the time you have available.  Starting the timer gives a feel of commitment about doing something NOW instead of  in a few minutes. Furthermore, having a timer tick back, give you back a bit of that deadline stress that makes you feel productive, without the disadvantages of real deadlines. And, not unimportant: it feels good to cross of real productive time.

Deadlines Are Killing

Wednesday, October 13th, 2010

My whole life I’ve been trained in sticking to deadlines.  School and University is nothing but doing a reasonable amount of work  for an event fixed in time (tests,  reports to hand in, etc)  Which, if you are anything like me,  means  procrastinating until the exact moment it can’t wait any longer an then work very hard.    Procrastination is rewarded:   it gives you more free time  and good results, so by the time  you get to your graduation, it has been perfected to find exactly the minimum amount of time needed to still get good results.

However, this skill gets you nowhere on real projects.  Projects like  your graduation or  developing a new product, where there is no fixed ending and you really want to get done as much as possible, as soon as possible.  ( I can probably make a todo list that fills the rest of my lifetime )  Of course there is the fun/interesting stuff that will never get you stuck, however every project (even the most fun ones)  have those tasks that you just need to get done. Not being able to do so in a timely manner is very frustrating.

The first obvious way to try and fix  this, is to create artificial deadlines, to get back that feel of urgency. However, deadlines that you set yourself don’t work, I’m just way to much aware how arbitrary they are.

Furthermore, on real projects, the amount of work is not known in advance. So there is no way to determine when to start to finish ‘just in time’. On the other hand lots of stuff you delay, might take far less time than you expected.  (You actually spend more time thinking about how much time it is going to take)

Procrastination is also closely related to getting ‘into the zone’ (Read: Joel Spolsky on that topic), but to be fair,  there are also lots and lots of activity that do not require any ‘zone’ at all. So, I feel a strong urge to  ‘solve’ this productivity mystery.   One of the obvious choices is reading about the ‘getting things done’  method. However I’ve never succeeded in making it work for me:  Writing everything down in a system, makes it even more overwhelming then just managing it in my head, as my brains are a lot better capable in hiding the ‘someday/unimportant’ stuff that I come up with.

I’m still in doubt though whether this is not just your brain telling you that there is only a fixed amount of productive time and the idle time in between is just needed to solve complex problems. However, there are a few things I did find, that do help:

  • Committing to a task, by telling someone that you will do it: ‘right now’.  (Not some time in the near feature, really: NOW)
  • Do another task instead, that you feel really passionate and confident about, to get going
  • Split up your tasks into such small subtasks that it’s impossible to not finish it (So every time you do any work, you actually finish something, instead of going from   ‘busy’ to ‘still busy’)
  • Work together on a project,  you can keep each other going  ( I believe that is one of the biggest arguments in favor of pair programming)

Are you a procrastinator as well?  And what do you do about it?

Slowing myself down

Friday, May 1st, 2009

My previous post was a bit generic, but now I’ve encountered the perfect example of how building a Framework slows you down:

Lets say we are building basic user account confirmation. In a plain-php way I would write:
mail($email, “Your account confirmation”, “….”);

Now in our framework it has evolved to something like:
mail($email,  $settings->getSetting(CONFIRMATION_MAIL_TITLE), “…”);
and the actual text is loaded from the settings table in the database (so our non-tech partners can edit as well).  So all is now configurable and nice and quick and smart right?

NO, because in a new project, the database is clean, so I get a nice “confirmation.mail.title setting is not defined”.    And now this is where I slow myself down:  Instead of just adding this entry to the database I think:  hey, I shouldn’t get this error, this should have a default setting.   So now instead of having to write this one simple line of code I have to:
– find a way to store all default settings in some file in the framework distribution
– adjust the settings mechanism to use those defaults if there is nothing in the DB
– retrieve all data in the settings table from a previous project and store it in the file

And as soon as I have this thought cross my mind, the focus on the original project is gone and we are back at the infinite task of the perfect framework.