I'm rewriting somebody else's code at the minute, and I came across two classes which reference each other directly and call methods on each other. Like so (example in C#):
class A {
B otherClass;
public A() {
this.otherClass = new B(this);
}
// Other methods here call methods on B
}
class B {
A otherClass;
public B(A otherClass) {
this.otherClass = otherClass;
}
// Other methods here call methods on A
}
Reading through his code and trying to understand it, I'm having to move between the two classes as they call each other.
These classes are not independently reusable without using the other. I'm aware it's considered best practice to avoid circular references (and it's straight up not allowed between C# projects in Visual Studio), but is this, or could this be, in your experience any better than having a single - larger - class?

$window->addButton(new Button($window));UI libraries do it all the time! – Mathew Foscarini Feb 10 at 20:48