I just wanted to ask for your opinion on a situation that occurs sometimes and which I don't know what would be the most elegant way to solve it.Here it goes:We have module A which reads an entry from a database and sends a request to module B containing ONLY the information from the entry module B would need to accomplish it's job (to keep modularity I just give it the information it needs -> module B has nothing to do with the rest of the information from the read DB entry). Now after finishing it's job, module B has to reply to a module C if it succeeded or failed. To do this module B replies with the information it has gotten from module A and some variable meaning success or fail. Now here comes the problem: module C needs to find that entry again BUT the information it has gotten from module B is not enough to uniquely find the exact same entry again.I don't think that module A giving more information to module B which it doesn't need to do it's job but which it could then give back to module C would be a good practice because this would mean giving some module information it doesn't really need.What do you think?
Is it bad practice for a module to contain more information than it needs?
control structures;dataflow
Getting information from one part of a program to another is a constant battle and there is pretty much never a perfect solution.I can see four possible solutions in a situation like this:Just go ahead and include the information that C needs in the call to BA calls C with all of the information and C calls B with just the information that B needsPut all of the information into a neutral object that both B and C can access and let each of them get what they needA calls B with just the information that B needs, B returns pass/fail, A calls C with information C needs (introduces dependency of A on C but removed dependency of B on C)The best solution will depend on the circumstances that actually exist in any given situation.