Ideally you are matching the insulin activity to the release of glucose into the bloodstream.
Different insulins have different activity profiles - each manufacturer provides a pretty graph of available insulin vs time for each insulin they make. NB these graphs are averages over thousands of measurements and probably won't exactly fit you
Our glucose, well my glucose anyway, comes mostly from carbs, and they vary as to how fast they produce glucose. If you're going to eat pure sugar (as fast as it gets) inject way ahead of eating. White bread is faster than brown bread etc. For me, cheese delays glucose production enough that if I eat fondue I can't inject before eating. YMMV
And the absolutely most irritating thing of all? It's all entirely dependent on your metabolism, which means something that works for one person may or may not work for you.
Injecting after meals? Test your blood glucose and see how high you spike, then decide if you are OK going that high.