Keeping battery charged at certain level
The 40% charged state is applicable for Lithium-Ion batteries only if you're going to remove the battery and put it in long term storage without using it. Refer How to Prolong Lithium-based Batteries. In the case of MacBook models, Apple recommends storing the batteries at 50% charge if you do not plan to use it for more than six months.

For normal usage, Apple recommends that you run the laptop on battery once in a while and also do a full discharge and recharge to calibrate the battery (full discharge/recharge means running it down till the computer automatically goes to sleep or shuts down due to low battery and then recharging it completely to 100% in one go).

Apple laptop batteries - Standard Maintenance


  For proper maintenance of a lithium-based battery, it’s important to keep the electrons in it moving occasionally. Apple does not recommend leaving your portable plugged in all the time. An ideal use would be a commuter who uses her notebook on the train, then plugs it in at the office to charge. This keeps the battery juices flowing. If on the other hand, you use a desktop computer at work, and save a notebook for infrequent travel, Apple recommends charging and discharging its battery at least once per month.


See Apple's guide on Notebook batteries for detailed information.