People tend to do two things. What they think is fun and what they are measured on.
Measuring is a two-edged sword and should be used with prejudice.
Giving people fun things to work with is more like icecream with a strawberry on top.
People do things they are measured on. Since one cannot measure brilliancy and why-you-rise-in-the-morning, measuring tends to give focus to other things like klocs or amount of green unit test lights.
I worked with a guy who was fast as lightning with the drawback that everything was finished the first day; often even before the code was written. So instead of harrassing him about estimates and CRUD I let him hack away and just finished what he started. His focus was code code code and my became customer satisfaction. Both of us where satisfied.