Reason not to implement Database.AllowsCallouts

I have a number of batches all extending a base batch class that handles logging of sorts. Some of these batches do callouts, while others just handle data in Salesforce alone. It happened to me on several occasions that I forgot to implement Database.AllowsCallouts on new batches that do callouts, so I was thinking of simply adding it to my base class. This means that the batches that extend my base class that do not do any callouts will also implement that interface. Would this do any harm to the performance? Would there be any reason to specifically add it only to the batches that actually need it?


Interfaces such as Database.AllowsCallouts or Database.Stateful can be considered as Marker Interfaces. They do not bring any overhead to the implementing classes but it’s a marker to the runtime virtual machine to treat any implementing classes in a special way. Although not specifically stated in Apex Developer Guide, but you can find a reference of Marker Interface on Aura Components Developer Guide.

The design strategy as if you want to implement at the parent or child classes are totally fine, you can take the call based on how much effort you want to spend in modifying the classes. If I were to write something like this, I would have included this interface at the parent level so that I don’t have to individually modify all the child classes.

Source : Link , Question Author : rael_kid , Answer Author : Jayant Das

Leave a Comment