Nowadays, the premier technology today for portable products is lithium ion (Li-Ion) batteries. Batteries have a limited number of recharges before it begins to lose its original max energy retention. As time goes by, instead of being able to recharge your battery to its full capacity, your battery will begin to charge itself up to only 95%, then to 90%, and so on. Batteries naturally lose storage capacity as they age due to secondary chemical reactions within the battery whether or not it is currently in use. Besides the natural aging of the battery, there are other factors that effect the life of your battery.
The memory effect is an observed effect in nickel cadmium batteries that causes them to hold less charge when they are repeatedly recharged only after being partially discharged. The battery "remembers" the smaller capacity and the battery begins to adjust itself to create a lesser "maximum capacity".
A battery's life can be severely affected by overcharging (where the charger applies more than enough energy to the battery) and over-discharging. The heat produced by overcharging also damages the life of the battery. Investing in a cooling pad for your laptop will help reduce the heat being generated. It would also be a good idea to keep your battery away from hot conditions like laying out in the sun or near a hot surface. Overcharging over long periods of time produces voltage depression where the peak voltage of the battery drops. Overcharging will sometimes cause the formation fo small crystals of electrolytes on the battery's plates, which can clog them and therefore increase resistance and lower the max voltage in battery cells. This decreases the amount of charge the battery can hold.
For laptops, if you know you're going to constantly connected to a power source for a long period of time, remove your battery . In some cases, deep charge/discharge can help extend the life of your battery by returning it back to (or closer to) its original max capacity. What you need to do is to repeatedly recharge your battery completely and discharge it for a couple cycles. This works particularly well with batteries with a single cell. For multi-cell batteries, some cells may discharge completely before others, which may cause some damage, furthering the decrease in battery life. It is not a good idea to fully discharge Li-Ion batteries, because Li-Ion batteries are not affected by the memory effect. Doing so may cause damage and shorten your battery life because fully discharging the battery will fully discharge the cells in the battery causing damaging.
As for extending the life of your battery during use, here are a few tips on how to do so.
Another tip to extend the life of your iPhone is to leave the WiFi on, especially when you are constantly using it for email updates. Rather than forcing your iPhone to spend energy being on the look out for email updates, let the WiFi networks perform that task. This reduces the amount of energy your phone uses and will extend your battery life.