Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with circular references?

If I have those two projects:

MyCompany.ERP.Billing MyCompany.ERP.Financial 

Billing asks/sends information to Financial and vice-versa. Both are too big so I don't want to put them in a single project. Visual Studio doesn't allow circular references. How would you deal with that?

like image 562
Eduardo Avatar asked Sep 15 '10 16:09

Eduardo


People also ask

How do you overcome circular references?

To fix the problem, you can move the formula to another cell. Press Ctrl+X to cut the formula, select another cell, and press Ctrl+V to paste it. You can also try one of these techniques: If you just entered a formula, start with that cell and check to see if you refer to the cell itself.

Is it okay to have circular references?

Circular references aren't a bad thing in itself: you can use them to achieve complex calculations that are otherwise impossible to do, but first you must set them up properly.

Why do I keep getting a circular reference in Excel?

%) error message explained. Millions of people using Excel don't get why they see the “circular reference” error message right after they've entered a formula. The message means that your formula is trying to calculate its own cell–kind of like when a dog chases its own tail.

How do you avoid circular reference interest expense?

In financial models, the best way to avoid circular references is to build in a “switch” that lets the user toggle between Average Balances and Beginning Balances when calculating items like Interest Income and Interest Expense.


2 Answers

Extract interfaces from your classes and put them into a core project referenced from both Billing and Financial projects. You can then use those interfaces to share data between assemblies.

This only allows you to pass objects between those 2 assemblies, but you can't create objects from the other since you don't actually have a reference to begin with. If you want to be able to create objects you need a factory, external to those 2 projects, that handles object creation.

I would extract the business logic that needs to share the data back and forth between Billing and Financial into another project. This would make things a lot easier and would save you from resorting to all sort of tricks that make maintainability a nightmare.

like image 168
devnull Avatar answered Sep 22 '22 21:09

devnull


Having too large of a project shouldn't be an issue. You can keep your code structured with namespaces and different folders for the source code. In this case circular references are no longer an issue.

like image 45
PhilB Avatar answered Sep 21 '22 21:09

PhilB