So why did we create and call the
start method instead of just changing the
started property directly? Using a method to change a property is another example of encapsulation whereby we can often improve the maintainability and extensibility of code by letting an object worry about how it gets things done. It’s better to have a
start method that knows how to start the car than for you to have to know “to start the car we need to take the
started variable and set it to true.”
Now you may still be saying “What’s the big deal? Why not just set the property to true to start the car?!&...
What is object encapsulation?