Short Answer
First of all, let me say that I love rain barrels, and have them installed at both homes I've owned (both older homes that are already fully landscaped). I think rain barrels are great water saving devices, and can provide some buffer against run-off. They're also cheap and easy to install, and can often repurpose existing containers.
However, I would still answer "No, they should not be considered substitutes for rain gardens in building codes".
Why
First of all, we need to understand what the purpose of a building code is. It's not a way to create the best possible residential units. It's a means to provide sort of a lowest-common-denominator solution. A minimum acceptable standard for something - in this case, stormwater management.
Someone such as yourself, who's in tune with these issues, an active gardener, and motivated to consider sustainability, might very well be able to improve upon the building code's solutions. But, the code isn't so much for you, as it is for those who don't care about this stuff.
For rain barrels to perform a stormwater management function, requires some active management on your part. As Highly Irregular said, you have to watch the fill level of your barrels constantly. Most residents won't do this reliably. A 55 gallon rain barrel can fill up fast, so it's easy to envision that in a short time, it might have zero benefit for stormwater management. If the barrel is full, and has to drain via the overflow tube, you get absolutely no drainage benefit. The rain garden is much more work to setup, but in my opinion, once it's working, it should continue to function with less intervention, compared to the rain barrel. If the right native species are planted, once established, you should only have to make sure somebody doesn't completely mow over the garden. Any other maintenance should be few and far between.
Also, building codes primarily serve to govern plans for new buildings. When you have an empty lot that's yet to be landscaped, it's less work to install a good rain garden. After the home/building and yard are complete, and you want to add additional water management, I think rain barrels offer a reasonable retrofit solution.
Parallels
To me, this also reminds me of geoengineering solutions, which I generally tend to be opposed to. For example, a proposal to combat global warming by injecting sulfate aerosols into the stratosphere. True, this would block sunlight, which would have a cooling effect. But, sun is a good thing. Blocking it would have other detrimental effects, and this "solution" does nothing to fight the non-warming problems associated with increasing CO2 levels (e.g. ocean acidification).
Actively managed rain barrels might serve the purpose of stormwater management, but a plastic barrel isn't a plant. Rain gardens are also good because they involve planting native species, keeping greenspace green instead of turning it into concrete, patio or deck area, and they also promote good biodiversity. Rain barrels by themselves don't do these things. The only thing they're assured of doing is saving some water.
Conclusion
Saving water is good. I use rain barrels, and especially recommend them for retrofits, where the yard is already planted (with or without rain garden). I just don't think they're a substitute for rain gardens in building codes.