Meal Maker project Code Critique

Hello all,

Linked below is the code I came up with for the Meal Maker project. Upon completion, I decided to look through the hints and forums to see if I had come up with the code that I was essentially supposed to, and have noticed some differences between my code and others. Specifically, I’ve noticed lots of people putting the setters and getters for the _courses object as direct elements of the menu object, rather than inside _courses, like how it was in the lesson. I figure this would work just fine as long as you are context aware in regards to the this keyword, and properly tell your setter/getter to go inside the _courses object to set/get whatever you need, but this seems like it’s eschewing the intent of getters and setters and how they’re meant to be used.

What I’ve also noticed (and I believe this to be true of the walkthrough video linked with the project) is that some people tend to be including the getters and setters, then writing code that seems to not invoke them at all, simply just reading/writing those values manually by going into the menu._courses[courseName] to pull the array directly (unless I’m seriously missing something here).

With my code set up the way it is, it seems to be what the project was actually meant to be. The setters and getters are included on the object they actually apply to, and methods for adding dishes to the courses that actually utilize the setters, likewise for getters.

The getters and setters lesson mentioned trying to find out what happens when you make a getter/setter the same name as the property it’s trying to get/set. With how my code is set up, making these the same name breaks the code, so I used the underscore method from the lesson to differentiate, even though that seems to go against the instructions.

Any pros or cons to the way I’ve done this project? Have I missed any details about the core concepts? I’m open to any constructive criticism or explanations. I can see that lots of people tend to struggle to see the usefulness of setters and getters, which I believe is what’s lead to me seeing many instances of code that functions perfectly fine, but simply doesn’t use the setters/getters.

Your approach is a bit different from what I believe is intended in the exercise, you have defined the getters and setters within the _course object, which I believe is different than what others are doing.