Generally speaking not using the battery when it's not necessary to, but making sure to run at least one full cycle every month is what you'll want to do.
Hypothetically, if you were to never use the battery, except for a full cycle once a month, that would lead to maximum lifespan, but of course then why are you even using a laptop?
I'd say so long as it's plugged in when convenient, it's probably fine.