MEAL-MAKER (getter and setter explanation)

Hi, just finished the meal-maker project, it’s working fine but I’ve checked the solutions and noticed that the ‘getter-setter’ part was wrong.
I removed the whole part, and it is still working, can someone please explain why is it necessary and how does it really work?
Best,
Erick

Hi,

This is an early example of what a programming paradigm feels like. By paradigm I mean, loosely, a style of principles and thoughts behind how code should be structured.

The particular paradigm getters/setters adhere to is object-oriented programming (OOP). It is generally considered good practice to have them even if your code would run either way.

Obviously, alarm bells should ring when anyone says “it’s good practice”. The research you’d have to do now is why it’s considered good practice. Still, even if after research you believe it’s not essential, whenever you integrate into a team or want people to work with your code, they’re going to expect some sort of organization, so if you choose to not use it I recommend having a strong common alternative if you can find one. I’ll leave the research and opinions to your discretion.

3 Likes

Thanks for your reply, now I understood. The fact is that I didn’t get the whole idea for getters/setters, I will revise these lessons too.
Best,
Erick