Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any hacks to resolve circular reference problems?

Tags:

c#

I inherited a code base that wasn't well thought out, and am running into some circular reference problems. My team doesn't currently have the time or resources to do a huge refactor, so I was wondering if there was some switch that I could flip that says "build these two dlls atomically."

A simplified example:

DLL D0:
    class A1 -> References B1
    class B1 -> References A1

Class A1 and B1 have references to each other, and as they're in the same DLL, this is fine - but they don't have much in common so I want to break them out into separate dlls.

However, the following is impossible because of a circular reference problem:

DLL D1: class A1 -> References D2.B1
DLL D2: class B1 -> References D1.A1

I want to be able to tell MSBuild to build (D1+D2) as if all of the code were in a single dll. Is there anything I can do here or do I follow SOP and "hack it in?"

Disclaimer: I understand this implies I have a much bigger problem with my model (the most glaring is an improper use of interfaces), but in the small company, real world scenarios dictate that I bend over backwards to fix production bugs at the expense of best practices.

like image 932
Michael Avatar asked Jan 16 '13 19:01

Michael


People also ask

How can I get around circular reference?

Click the "Formulas" tab in the ribbon menu at the top of the Excel window. Click the small arrow next to the "Error Checking" button in that area. Move your mouse over "Circular References" and the last entered circular reference will appear. Click on this reference to jump to that cell on the spreadsheet.

How do I bypass a circular reference in Excel?

To start, click on the 'File' tab. On the 'Excel Options' window, go to the 'Formulas' section and tick the 'Enable iterative calculation' box. Click 'OK' to save the changes. After that, you will not get any warning whenever there's a circular reference.

What is the fastest way to find circular references?

Manually detect Circular References in ExcelGo to tab 'Formulas', choose 'Error-checking' and 'Circular References'. Excel will show you exactly in which cell(s) circular references are detected.


1 Answers

My team doesn't currently have the time or resources to do a huge refactor

so... DO NOT DO THIS:

but they don't have much in common so I want to break them out into separate dlls.

Leave it alone until you can apply significant refactoring to the whole solution.

This is a case where refactoring an organizational peeve will force a huge amount of refactoring down stream. And you have much bigger problems to deal with. I've been there. I feel for you. Good luck mate.

like image 82
Paul Sasik Avatar answered Sep 20 '22 05:09

Paul Sasik