Use a double boiler to melt the butter with the sugar, chocolate (or cocoa powder). You have more control over the heat and can a avoid burning the mixture.
If using eggs in the batter don’t add these to a too a hot chocolate mixture, the mixture should be cool to the touch. Otherwise, you will have scrambled eggs in the mixture.
Don’t over beat the mixture when combining the dry and wet ingredients. Rather gently fold the dry ingredients with the wet and only until the dry is fully incorporated.