Is it better to use a laptop on battery or on AC power?

It won't make all that much difference. What will shorten battery life is temperature: If it gets hot, it will shorten the battery life. Best thing to do, if you are able, is to remove the battery while you're at home and keep it somewhere cool.

If it's a Li-ion battery, then they don't like to be completely discharged, so make sure you charge them regularly. Wikipedia:

Lithium-ion batteries should not be frequently discharged fully and recharged ("deep-cycled"), but this may be necessary after about every 30th recharge to recalibrate any electronic charge monitor (e.g. a battery meter). This allows the monitoring electronics to more accurately estimate battery charge.[26] This has nothing to do with the memory effect.

More tips can be found here:

  • http://batteryuniversity.com/learn/article/do_and_dont_battery_table
  • http://web.archive.org/web/20090811004517/http://www.friedbeef.com/top-15-ways-to-extend-your-laptop-battery-life/
  • http://en.wikipedia.org/wiki/Lithium-ion_battery#Guidelines_for_prolonging_Li-ion_battery_life
  • http://ask-leo.com/how_do_i_maximize_my_battery_life.html

Apple has a good page on lithium ion batteries which should apply across the board to other manufacturers, not just Apple. Basically, keep your device (laptop, phone, etc) plugged in whenever possible. When the battery is discharged to around 70-80%, recharging will be another cycle, and batteries only have so many cycles before they need to be replaced.

It is good for the battery to be completely discharged every so often, about once a month.