Friday, January 27, 2012

The Little Redis Book

Redis is a high-performance in-memory data store, similar to memcached but with a number of advanced features including more datatypes (strings, sets, sorted sets, lists and hashes), a pub/sub mechanism, various options for data replication and persistence and a number of other interesting and useful features. There's a new e-book about it that covers a lot in only a few pages, and is also free. Check it out: The Little Redis Book

Thursday, January 12, 2012

Driven: How Human Nature Shapes Our Choices by Paul R. Lawrence and Nitin Nohria

In Driven: How Human Nature Shapes Our Choices, Harvard Business School professors Paul Lawrence and Nitin Nohria present a unified theory of human motivation. They identify the following four primary drives, each unique and separate from each other in significant ways such that they cannot be reduced further, and which together form the basis for other drives. They are:

D1. The drive to acquire. This drive includes the desire for objects of value and unique experiences, status and influence. Sexual conquest would fall under this desire, while sexual intimacy would be D2.

D2. The drive to bond and form long-term relationships.

D3. The drive to learn, to increase our understanding of ourselves and the world around us.

D4. The drive to defend our self, our loved ones, our possessions, our community and our beliefs.

The authors begin by attempting to explain their background, and how the narrowed focus of the vertical scientific disciplines have been unable to arrive at a unified theory of why we do what we do. By tracing back to earliest humanity, when the great leap in human intelligence and/or society occurred, they point to a biological basis for the drives that was reinforced by successful evolution.

Each of the four drives has a positive and negative side. In moderation, each drive aids survival, and can help the species to thrive and to be happy. However, when carried to extremes, each drive can be destructive.

In the final part of the book, the authors point out how knowledge of their four drives can be used to build environments where people can prosper and thrive, meeting each of their four primary drives, and they point out two case businesses as case studies. They discuss HP as a model of a company that embraced all four of the drives to create a successful culture. The “HP Way” was based on the principles of individual ownership and responsibility, collaboration within groups, knowledge sharing, and a sense of community.

Unfortunately, Driven teeters awkwardly between a scholarly work and a book aimed at the mass market. On one hand, they try to build a solid case for why their four drives are necessary and sufficient based on studies in various fields. On the other hand, they then make a series of unsupported off-the-cuff remarks that greatly undermine their credibility. The writing itself is quite dry, and they spend far too much time talking about their credentials and editorializing.

Key ideas: Humans have four primary drives, the drive to acquire, bond, learn and defend that are all critical for our survival and success. Although the relative intensity of each drive will vary from person to person, we require all four to be met, and a successful business or social environment will address all four needs. Defending our beliefs is a core drive. In the same way that we rise to the defense of our community, we defend the ideas that we have adopted when they are threatened.

It is interesting to compare Driven with Drive by Daniel Pink. Pink talks about the need for autonomy, mastery, and purpose, and also addresses the need for payment as well. However, his goal is to identify the situations in which intrinsic motivation can flourish, assuming that the basic need for compensation has been addressed. Pink perhaps pays too little attention to the need to acquire/gain status, but his thesis is that those are primarily extrinsic motivations that science has shown to have a negative or at best neutral impact of creative thinking.

I listened to the unabridged audiobook version from Audible.

Thursday, January 5, 2012

Review: Drive: The Surprising Truth About What Motivates Us by Daniel Pink

In his 2011 book Drive: The surprising truth about what motivates us, Daniel Pink offers a compelling and intriguing case for what he terms Management 3.0, the principles that will guide management in the 21st century.  Motivating knowledge workers, people who must exercise creative thinking to solve novel problems in new and unique ways where the correct answer is not even clear from the start, is significantly different than for the more manual and/or repetitive task-oriented workers that have been common for the last 150 years. In particular, creative thinking is significantly enhanced by intrinsic motivation, and impaired by extrinsic motivation, so the goal of management will be increasingly to set up situations that foster intrinsic motivation. Surprisingly, the effects of traditional extrinsic carrot (bonus/equity/perks if/then thinking) and stick (firing/humiliation/pressure) can actually impair creativity. Pink points to the following three principles for fostering intrinsic motivation:

1. Autonomy. Control over the four 4 Ts.
  • Time (when work is done. Flex time)
  • Tasks (what gets done. Allow people to pursue their own solutions to problems)
  • Technique (Allow them to implement the solutions as they see best)
  • Team (Allow freedom to collaborate with people of their choosing)
2. Mastery. People naturally want to become better at the things that they do. Enable people to continually improve by pursing "goldilocks" tasks: things that are not too easy, but not too hard. Strive to create "flow", the optimal state where focus, ability and desire converge. Encourage a climate of perpetual improvement, limited only by a person's desire to discover, learn and practice new ideas and techniques.

3. Purpose. People have a need to take part in something bigger than themselves that has greater meaning. Clarify what that larger purpose is, and

Citing a number of scientific studies, he points out that behavioral scientists have known about these ideas for decades, but that traditional management has been very slow to adapt to the changing science. For example, managers and companies should seek to remove compensation from the discussion, rather than motivate workers through bonuses. Multiple studies confirm that rewards-based compensation is actually counter-productive for tasks requiring creative thinking and problem-solving (although it IS effective for tasks with requiring little or no creativity). Pay employees a fair/good salary (relative to their peers, and to the industry), and allow them to focus on the intrinsic motivation of the job. Use pay to attract and retain talent. See also "Good to Great" for a detailed discussion of this idea.

In addition to management, Pink points out that the same ideas can be applied to education and child-rearing. As nearly all the tasks that are routine or well-suited to automation are leaving the US, the skills our children will require have shifted, and we need to shift our educational styles too. He includes a number of resources in the book, including a detailed summary of the contents.

Key idea: Fostering intrinsic motivation is key to tasks that require creative thinking. Autonomy, mastery and purpose are the building blocks of intrinsic motivation.

Other interesting ideas:
  • Management is a technology, not an innate human condition. Be aware and treat it as such.
  • Companies like Google use 20% time to give greater autonomy and drive innovation. End result: successful new products
  • Results-only work environments (ROWE) are pioneering even greater  workplace autonomy
This is one of the most important books I read in 2011. Backed up by research, and presented in an entertaining and though-provoking way with concrete examples, the books makes a solid case for change. Pink goes out of his way to make the ideas easy to absorb, providing a number of resources like a detailed summary that can serve as a refresher, and a number of conversation starters.

There are many parallels to the ideas discussed in Good To Great. In particular, while GTG talks about the importance of hiring self-motivated people, and then not demotivating them, Drive fills in the gaps to explain how specifically to encourage self-motivation.

One area for further exploration would be the crossover between intrinsic and extrinsic motivation. I don't believe that the lines are as clearly drawn as Pink posits. For example, the successful person who states that they were driven (intrinsically motivated) by the burning desire to "not be poor", to provide security and safety for their families, or to be remembered, all of which would be fall in Pinks classification as extrinsically motivated, but which also share some elements of a greater purpose.

See Also:


Wednesday, December 28, 2011

Tasksets in Gearman

Here's a little tidbit about using the Gearman Perl Client:

Gearman is a powerful yet simple job queuing and distribution framework with clients in a variety of languages,  written by the Djanga folks (who also wrote memcached).

For a recent project, I needed to be able to queue up a potentially large number of jobs during one phase of execution, and begin processing them  went out to find more work to queue. At some point, we would know that we had no more jobs to add to the queue, and would be ready to move on to the next stage when all the jobs had completed. Gearman::Client provides a synchronous "do_task()" method that waits for a task to return its result, and a "dispatch_background()" method that runs jobs in the background. The limitation of background jobs is that it does not return results: you are merely able to monitor the status of the job to see when it completes. Task sets to the rescue!

Task sets allow you to group a number of jobs together, begin executing them immediately in the background, but with full access to the return values, errors and retries via event handlers. Furthermore, task sets provide a wait() method that will wait until all jobs have finished (either succeeded or failed), which was exactly what we needed.

Here's some sample client code that I used to verify this functionality:

1:  #!/usr/bin/env perl  
2:  use strict;  
3:  use warnings;  
4:  use Gearman::Client;  
5:  my $client = Gearman::Client->new();  
6:  $client->job_servers("localhost:4730");  
7:  my $tasks = $client->new_task_set();  
8:  for my $count ( 1 .. 10 ) {  
9:    $tasks->add_task(  
10:      echo => $count,  
11:      {  
12:        on_complete =>  
13:         sub { my $result = shift; warn "from job $count got " . $$result; },  
14:        on_fail => sub { warn "ERROR from job $count"; }  
15:      }  
16:    );  
17:  }  
18:  warn "done adding tasks";  
19:  sleep 5;  
20:  warn "waiting";  
21:  $tasks->wait;  
22:  warn "bye";  

The critical part of this prototype was to verify that jobs began to be processed by workers when the job was added to the taskset on line 9, and not only at the call to wait() on line 21. 

And here is the trivial echo worker that returns whatever you send to it:

1:  #!/usr/bin/env perl  
2:  use strict;  
3:  use warnings;  
4:  use Gearman::Worker;  
5:  sub echo_worker {  
6:    my $job = shift;  
7:    my $arg = $job->arg;  
8:    warn "ARG: $arg";  
9:    return $arg ;  
10:  }  
11:  my $w = Gearman::Worker->new();  
12:  $w->job_servers( "localhost:4730" );  
13:  $w->register_function( echo => \&echo_worker );  
14:  $w->work while 1;  

Without tasksets, it would have been substantially trickier to 

Tuesday, December 27, 2011

Review: Switch: How to Change Things When Change Is Hard

I recently completed the audiobook version of  Switch: How to Change Things When Change Is Hard by Chip Heath and Dan Heath. In this excellent book, they break down change factors into three components: the logical mind, the emotional mind, and the environment. Borrowing a metaphor from another excellent book, The Happiness Hypothesis, they characterize human decision making as a rider perched atop an elephant. Although the rider (the logical mind) has the power of foresight, thinking and planning for the future, he can only exercise limited control over the greater strength of the emotional mind, the elephant. When emotions take over and runs wild, the tiny rider has only limited control and must hang on for the ride. The rider thinks about tomorrow, skipping the cake today for a healthier body next summer. However, without the elephant, the rider has difficulty making decisions and taking action. They summarize their recipe for change as follows:

1. Direct the rider. Often what appears to be inaction or resistance is simply confusion. Script the critical change steps into simple, crystal-clear actions that can be easily followed. Look for early, or previous successes (bright spots), and identify the key components to change. Often large, complex problems seem to demand complex solutions, but by looking for common elements in the bright spots, we can make progress through simple steps. For example, a weightloss campaign that targets whole milk as the largest single source of fat simply suggested buying skim/1% milk and was effective. Solutions-based therapy is another example of the "bright spot" technique. When in your relationship/career/life were you happy.

2. Motivate the elephant. What looks like laziness is often exhaustion. People have a limited amount of self control, and expending this control fighting their elephant decreases their capacity for other efforts. Make an emotional appeal that is directed at making people feel something. Aligning logic and emotion is critical. Knowledge does not bring about change, only emotion and desire change behavior. Powerpoint displays rarely get peoples' blood boiling, so find more visceral ways to get your point across. In one example, as part of a campaign to reform corporate purchasing, a glove shrine with more than 400 gloves, many identical except for their prices, was piled on a fancy executive's table to demonstrate the insanity of each business unit independently negotiating  and purchasing its own supplies. Always think, "what is the feeling here".

3. Shape the path. What looks like a people problem is often a situation problem. A good leader doesn't ask "what's wrong with these people, they just aren't getting it". Rather, consider what factors in the environment can be changed to influence the outcome. As an example, they described an experiment in which people at a movie theater were given large or extra large buckets of badly tasting popcorn. Repeated experiments confirmed that people given the extra large buckets ate more. Changing the bucket size changed behavior.

Other ideas:

Rally the herd: Use peer pressure to drive conformity. If the majority of people are already doing the desired behavior, publicize it and encourage people to do the right thing. For example, publicize that 70% of employees get their expense in on time, or 90% of reviewers complete their review within X amount of time. As a corollary, don't publicize statistics that reinforce undesired behavior, e.g. only 30% of employees submit their expense reports on time.

Make use of action triggers. Encourage behavior by tying it to a specific time and place or event. For example, ask employees returning from a conference to "write up some notes for the team when the fasten seatbelts sign goes off on the flight home". Students asked to write a paper over break did better when they specified when and where they would write it.

Use checklists. The "lowly checklist" is extremely effective at making sure that procedures are followed, or ideas are primed. For example, the "cisco pre-acquisition checklist" was a useful tool for ensuring that basic questions were asked prior to acquisition.

I highly recommend Switch: How to Change Things When Change Is Hard for anyone attempting to create change at the personal, organizational or even societal level.