Depends on what IDE and which language do you use, and how often you compile the app.
For example if you use notepad (ha-ha) for c++, it will last forever. Okay, much longer than anything else. Why? Because it won't use the CPU / etc for auto-complete, format, etc. Won't stress your computer. (For example if you'd code Java, it'd take a lot of battery power because even the IDE is resource-hungry. See an eclipse startup. You make some coffee, drink it, brush your teeth, AND its loaded.)
If you compile, you drain your battery. If you do something, it'll drain your battery. The concept is THAT simple.
I have a Lenovo ThinkPad T500 with a 9cell battery. It already lost some juice. However, I can code for 2 hours with maximum performance. That means everything is maxed out. 3 hours with dynamic CPU and about 6 with maximum battery life (so the IDE slows down sometimes. I use Code Blocks and Visual Studio). ALSO, you can put an extra battery into the ultrabay.