In the proof for Snell's law in physics, I don't understand why some variables are held constant and some not. Here's the proof:

Snell's Law - ProofWiki

They're taking the derivative of with respect to the length , as labeled in the picture above. Why in particular the length and not e.g. the length or perhaps ? How come all the other lengths are considered parameters i.e. why are we holding them in particular constant not in this context? Why do we choose and consider to be the actual variabel?

Note: I'm doing a similar assignment where I'm to maximize the area of a triangle and I'm having a bit of a hard time deciding with respect to which variabel I'm supposed to differentiate.