Multitasking, by definition, removes attention from that which is most important. In a fantasy world of fixed tasks and infinite schedule, this works great. Fortunately for me, I live in the real world of priorities and deadlines.
A simplistic, but useful model:
1) Determine the most important task
2) Focus on the most important task
3) Complete the most important task
4) Go to step 1
Almost all interruptions will force a context switch, and all context switches force an implicit and natural restart at step #1: "Where was I at on that task again? Hrmm, oh yeah..."
Whenever I have problems with the above model, it's usually for a very small number of reasons:
The task was too large
I was unable to maintain focus for a sufficient period of time to complete the task. Natural interrupts, like sleep, result in context switches. This is usually not all that bad. Stopping for dinner, or for the night, gives a chance for my brain to rewire itself around the problem. The problem occurs when I restart at step #1 and determine that the most important task has changed.
The task was too complex
I was unable to keep the entire problem in my head at the same time. This causes internal multitasking and context switches within the scope of the "task". Solution: Keep tasks small, and try not to work on a problem I can't fit in my head.
External interruptions
Solution: Turn off email, phones, and IM for a while and focus on the task at hand. Let people know I'm focusing on the priority items, and for the next few hours, they are not my priority.
Whenever I hear someone brag about their multitasking skills, this is what I usually think:
- They apparently have no problem avoiding their high-priority tasks
- Or, they have no high priority tasks
- Or, they have a lot of menial tasks with low overhead/context switching costs
- Or, they're just full of shit
Saturday, October 16, 2010
Monday, October 4, 2010
No Cucumber for Python?
Edit: ylluminate posted a comment about freshen, which seems to be exactly what I'm looking for.
--
It would seem that nobody in the Python world is much interested in Cucumber. I've given thought many times to this and wondered, how hard is it, really, to implement Cucumber in Python?
Tonight I made an attempt to create a reasonably Pythonic way of writing test steps. Here is what I have so far.
First, here are a couple example steps:
And the 'step' decorator:
I don't have a test runner yet, but here's a complete example for invoking the steps:
--
It would seem that nobody in the Python world is much interested in Cucumber. I've given thought many times to this and wondered, how hard is it, really, to implement Cucumber in Python?
Tonight I made an attempt to create a reasonably Pythonic way of writing test steps. Here is what I have so far.
First, here are a couple example steps:
@step(r'Given I set variable "(.*)" to "(.*)"')
def set_var(args):
context[args[0]] = args[1]
@step(r'When I request "(.*)"')
def urlopen(args):
context['response'] = urllib.urlopen(args[0])
And the 'step' decorator:
def step(pattern):
def outer(f):
@wraps(f)
def wrapper(statement):
match = re.match(pattern, statement)
print pattern
if match:
f(match.groups())
steps.append(wrapper)
return wrapper
return outer
I don't have a test runner yet, but here's a complete example for invoking the steps:
import re, urllib
from functools import wraps
steps = []
context = {}
def step(pattern):
def outer(f):
@wraps(f)
def wrapper(statement):
match = re.match(pattern, statement)
print pattern
if match:
f(match.groups())
steps.append(wrapper)
return wrapper
return outer
@step(r'Given I set variable "(.*)" to "(.*)"')
def set_var(args):
context[args[0]] = args[1]
@step(r'When I request "(.*)"')
def urlopen(args):
context['response'] = urllib.urlopen(args[0])
def go(statement):
for func in steps:
func(statement)
if __name__ == '__main__':
print context
go('Given I set variable "x" to "17"')
go('When I request "http://www.google.com"')
print context
Subscribe to:
Posts (Atom)