Skip to content

Passing parent object to child objects #2947

Discussion options

You must be logged in to vote

This is a choice you make based on abstraction and dependency management.

Yes, you can pass in just the id, making the choice that the parent knows what the child needs. And if that changes in the future, then you change the calling code.

Or you pass in the parent reference, making the choice that the parent doesn't know what the child needs, and allowing the child to pull whatever data is necessary.

I don't know that either is "correct" - it is a choice.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@michaelcsikos
Comment options

Answer selected by Chicagoan2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants