Optional Recitation: Algorithm Complexity and Class Review

author: Sarina Canelake, Massachusetts Institute of Technology, MIT
recorded by: Massachusetts Institute of Technology, MIT
published: Oct. 29, 2012,   recorded: January 2011,   views: 2648
released under terms of: Creative Commons Attribution Non-Commercial Share Alike (CC-BY-NC-SA)
Categories

Related Open Educational Resources

Related content

Report a problem or upload files

If you have found a problem with this lecture or would like to send us extra material, articles, exercises, etc., please use our ticket system to describe your request and upload the data.
Enter your e-mail into the 'Cc' field, and we will keep you updated with your request's status.
Lecture popularity: You need to login to cast your vote.
  Bibliography

Link this page

Would you like to put a link to this lecture on your homepage?
Go ahead! Copy the HTML snippet !

Reviews and comments:

Comment1 Warren Wise, December 9, 2012 at 5:21 p.m.:

The explanation of why getter methods are needed is incorrect. Returning a mutable object in a method definition will still create an alias. In the case of a list, you'd have to return a copy of the list in order to prevent aliasing. The getter method enables you to return a copy (which the instructor did not do in her implementation).

Additionally, getter methods allow you to change the internal representation of your data without impacting callers. This makes programs more maintainable as you can change your design decisions without affecting callers that depend on your code. Callers can rely on the method specification instead of on internal knowledge of the data representation.

Write your own review or comment:

make sure you have javascript enabled or clear this field: