Is usage of Nested classes and example of tight coupling?

163 Views Asked by At

I'm working on a game where I have a nested class which has to get access to the member functions and variables of the outer class in order to perform it's functionalities. In particular the outer class contains member functions and data related to game objects whereas the nested class extends an AnimationTimer which basically has to make use of the game objects position in order to draw them on the canvas. Also the outer class has to call the start() method on the AnimationTimer so there will definitely be a need for an instance of AnimationTimer in the outer class. Now since I'm a bit new to this, I'm kinda confused from this post so

  1. Is this really the case of a tight data coupling ?
  2. What do you suggest in this scenario, should I convert it into a non-nested class and access the "parents" member functions through the static modifier (in which case why would this be proper and why not) ?

Any suggestion is welcomed :)

0

There are 0 best solutions below