Hello,
I'm trying to figure out the best design pattern to insulate a child object from knowing too much about the parent object it is contained in.
For instance, with a parent class like this...
class Airplane { var seats:Array ... function removeSeat(seat:Seat) { // find seat object in seats array and remove it } }
child class...
class Seat { var rowNumber:int ... }
If I'm working in the context of the Seat object and I want to remove myself from my parent Airplane object, what is the best way of separating the Seat from knowing about where it is in the Airplane.seats array?
I know I can pass the Airplane parent object into the constructor of the Seat, then call the removeSeat method on Airplane to remove that Seat, but I want to the Seat knowing as little about the Airplane if possible. Any ideas?