• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Bi-directional navigation and circular dependancy  RSS feed

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this confusion. When objects of two classes A and B can call each other's methods, the relationship is bidirectional, right? Now to implement these A and B classes, A has to know about B and B has to know about A, so compilation is a problem. OK, one can get around compilation problem using reflection.
The real question I have is if circular dependancy is bad and implementing bidirectional relationship requires it, then bidirectional relation is bad? I am sure I am missing something because bi-directional relationship is quite common.

We have a scenario where facade builds the cache (a singleton), and inside those cache building methods there calls to facade to get data.
Is something wrong with this design?
Any help is very much appreciated.
-Roshan
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't say that it's *wrong* per se - just somewhat "smelly".
You might want to take a look at the practice ofDependency Inversion, though...
 
Roshan Lal
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ilja. I too feel it is smelly. Thanks for the URL, I will go there.

Originally posted by Ilja Preuss:
I wouldn't say that it's *wrong* per se - just somewhat "smelly".
You might want to take a look at the practice ofDependency Inversion, though...

 
sunglasses are a type of coolness prosthetic. Check out the sunglasses on this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!