I have 2 classes: Users & Courses.
Users will have a one_to_many relationship with courses. Once a user logs in, what’s the best way to display all of their courses? Should I create a function under Users that is called getAllCoursesByUser or should I create it under Courses? I’m confused as to where to place these types of functions.
I’d do it like this:
If you are able to access courses from the user directly, that only creates IMO unnecessary coupling between the
UserandCourseclass. But you can really do it either way.