You can either define Z = f(A,B), as you did, or Z = f(X,Y) as you asked.
Using the correct boolean operations both methods will produce the right output.
The difference is in the timing: Assume some arbitrary runtime T for the calculation of a boolean function f(). What is the runtime for Z = F(A,B) expressed in terms of T and what is the runtime of Z = f(X,Y), also expressed in terms of T? Hint: X = f(A,B) and y = f(A,B).
f() indicates the required boolean operation which are of course different for each output.