Bifalgorithm post · Computer science one · Example
How can adding an addCourse method make a Student object more flexible?
How can adding an addCourse method make a Student object more flexible? (Computer science one · Example) — "Alternatively, we could make our design a bit more…
Ideas in this flowchart
- Flexible object design can trade immutability for easier construction and modification.
- A Student instance can be constructed without providing a course schedule.
- Outside code can add a course to the schedule later.
- The addCourse(Course c) method performs this addition.
- Its implementation calls this.schedule.add(c).
- This alternative adds flexibility to the object.
- This alternative removes the object's immutability.
- Design is a balance and compromise between competing considerations.