Do not #01
If I got a penny every time I saw a check for an empty list is made before a DML operation…
List<SObject> records;
...
if (!records.isEmpty())
{
//a DML operation goes here, e.g. an update
update records;
}
I’m not sure when a change was made, but it’s been years since apex interpreter is smart enough to handle empty lists of records w/o biting off of any limits. So check it for yourself, increase API version if necessary, and do not do it anymore.
for (Integer i = 0; i < 1000; i++)
{
insert new List<Account>();
}// Number of DML statements: 0 out of 150
// Number of DML rows: 0 out of 10000
PS: in a rare cases, when you deal with legacy code and it’s impossible to upgrade to a newer version of API — use a centralized place where you will perform such check, e.g. introduce DML executor class.