I'm thinking awareness is going to be the key to defending against the 21ft rule, and, admittedly, it won't be 100%.
Pay attention to your surroundings and the other people in it. If you spot a potential threat (ie, very sketchy looking with hands in pockets) or a likely threat (ie, weapon in hand and obviously disgruntled), you will have to determine how to mitigate each threat independently. Is the threat stationary, moving toward you, or moving away from you? If moving, is it slow or fast? Is the threat obviously focused on someone else or you? What is the setting?
In my opinion, the best option is to reroute to avoid the threat. If detouring around isn't an option, turn around but watch you back.
If avoidance isn't an option but the threat isn't immediate, try to put some cover/structure and as much distance as possible between you and it.
If it is an obvious (weapon in hand) threat and focused on me, I would likely draw my firearm but not necessarily aim it. I would still have to bring it up to ready and aim, but I remove drawing complications out of the process.
The other end of the 21 foot spectrum and perhaps that of greatest concern, is the surprise attack. This is where I agree with Magoo and say move perpendicular to the threat. Get out of its way and draw on the move.
The cane and similar options are good for those that can't quickly move to the side or that just want to use one as an additional defense.
Either way, the need to practice and pay attention is very important in my opinion.
This is all just my opinion, and I hope to hear from those like Janich and Bane.