Why certain anti-diabetics like Glimepiride is taken before food and certain drugs like Metformin after food? What is the basis behind this advice?

If we are prescribing a combined drug with Glimepiride and Metformin, what will be the ideal advice? (before food or after food) and how can we justify this advice in combinations?