One of the most important things you can do to maximize battery life is to install adequate capacity to meet your needs, without exceeding the optimal discharge level of the batteries.
If you're using flooded-cell batteries with removable cell caps, check the electrolyte level monthly, and top up the batteries with distilled water as needed. On any battery, make sure cable connections are tight and clean and free of corrosion. Once cleaned, a coating of corrosion inhibitor like Boeshield T-9 is a big help. This bit of maintenance ensures that you'll get the most amp hours out of the battery for powering up your boat, and that the most amp hours will get back into the battery when connected to a charger.
Once all the above has been accomplished, the bottom line for extending battery life boils down to proper battery-charging regimens tailored to the battery type and size.
The last few years have seen marine battery-charger technology improve dramatically.
State-of-the-art units can be programmed for up to three different onboard battery types, and some provide an intermediate fourth phase (most have three) of charging called "pre-float" to better transition the battery from what's called the absorption phase to the float phase, to maintain a 100-percent charge level while automatically adjusting voltage to ensure no overcharging. A good one will come with a temperature sensor for mounting on the battery for a more precisely controlled output based on battery temperature, a highly recommended feature.
Recommended battery chargers are available from Blue Sea, Charles Industries, ProMariner, Mastervolt, and Newmar.