Algorithms and OOD (CSC 207 2014F) : EBoards

CSC 207.01 2014F: Extra Session 5 (Thursday, 2 October 2014)


What's on the quiz?

No, wrong class.

Do you write good recommendation letters for people who ask you to cover a particular topic at review sessions and then don't show up?

Um ... what do you think?

Can you critique random code?

for (int i = 0; i < items.size(); i++)

items.size() could be expensive. I'd use

int len = items.size();
for (int i = 0; i < len; i++)

And if I were thinking more in Java than in C, and wasn't mutating the ArrayList, I'd use

for (Item item : items)

Here's another one

LinkedList<Item> items = this.items;

It looks like you're just trying to save five characters while typing. And Java doesn't require you to write this.items; you can write items. (Sam != Java, but Sam doesn't like your strategy either.)

See our updated code at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC207/2014F/git/zoe6/src/com/farevee/shopping/NewCart.java

Thanks ZW.