Encapsulate Collection

refactorgram

class Person {              
  get courses() {return this._courses;}
  set courses(aList) {this._courses = aList;}

image/svg+xml

class Person {
  get courses() {return this._courses.slice();}
  addCourse(aCourse)    { ... }
  removeCourse(aCourse) { ... }