Click here to Skip to main content
15,884,648 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm developing a server-side project in c#. The project is like so, it has 'Admin', 'Security', and 'Communicator' which are all independent projects (class libraries). The Admin module handles all the client-side requests. If the request comes from the client-side, the Admin module passes the request to Security module. The Security module does all sorts of staff including decryption, validation, authorization etc. If the request from Admin module passes a chain of logic in the Security module, the Security module forwards the data to Communicator module. The Communicator module then performs its own logic. When the Communicator module is done, it then needs to pass the data to Admin module so that the Admin module will serve the response back to the client. Now, the issue is, Admin module references Security module, Security module references Communicator module, now Visual Studio can't allow me to reference Admin module from Communicator module because of circular dependency error. What should I do?

What I have tried:

I have tried submitting data to a cache folder and have all the modules read data from that folder and not talk to each other directly, but its cumbersome.
Posted
Updated 4-Sep-21 10:33am

1 solution

Surely, Admin references Security, which has a report-back mechanism? And Security references Communicator which should report back to it?

OOPs principles means that Admin "knows about" Security (because it has to to do it's job) but Security shouldn't have any idea of what called it, and the same applies to the Security / Communicator relationship.
Normally, the report back would be via a combination of events which the caller subscribes to, and properties and / or methods the callee provides to transfer data after it has raised the event.
 
Share this answer
 
Comments
Eugene Rutsito 5-Sep-21 6:20am    
Thank you @OriginalGriff. So to clarify, you're are saying I must implement my dependencies like so.

Admin--> Security--> Communicator.

Then to pass response back from Security to Admin, I implement some logic in Security using a series of events and/or delegates. The same goes for passing response data from Communicator back to Security and finally to Admin. Am I correct?
OriginalGriff 5-Sep-21 6:47am    
That's right - that way, the higher level doesn't need to know how lower level(s) implement things, and lower levels don't care what higher levels are or are doing - each level has a single responsibility and acts as a black box to higher ones.

Eugene Rutsito 5-Sep-21 8:05am    
Thank you so much...
OriginalGriff 5-Sep-21 8:28am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900