We need to know the conditions because backfiring under load typically means a weak spark, which can be for a great variety of reasons, while under deceleration, shifting gears, or while running downhill typically means running too lean, which can also be for a variety of reasons.
Sorry to disagree with an assistant guru of stuff, but spark and fuel are the two things that you do NOT know that you have. Backfiring means unburned fuel is getting into the exhaust, either because insufficient spark to set it off or because too-lean mixture to support combustion. If the problem is intermittant, as you hint at, the cause is more likely electrical, like an intermittant break or short.
Steve