Algorithms and OOD (CSC 207 2014S) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Java 7 API] [Java Code Conventions] [GNU Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2013F (Rebelsky)] [CSC 207 2013S (Walker)] [CSC 207 2011S (Weinman)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)] [Issue Tracker (Textbook)]
Overview
Admin
Why is Sam's an interface and most of the ones out there are classes?
Sam's were anonymous classes, so they were really classes.
For Dictionaries
public interface DictionaryFactory<K,V>
{
public Dictionary<K,V> dictionary(...);
} // interface DictionaryFactory
One factory for association lists
public class AssociationListFactory<K,V>
implements DictionaryFactory<K,V>
{
public Dictionary<K,V> dictionary(...)
{
return new AssociationList<K,V>();
} // dictionary(...)
} // class AssociationListyFactory<K,V>
Another factory for association lists
public DictionaryFactory<K,V> df = new DictionaryFactory<K,V>()
{
public Dictionary<K,V> dictionary(...)
{
return new AssociationList<K,V>();
} // dictionary(...)
};
Lots of uses ... if we have lots of strings to parse, we might pass in the things that turn strings into objects
Experienced Java programmers tend to use introspection in making factories.
Input
qsort(T[] values, int lb, int ub)
Goal:
Break into three parts (< pivot, = pivot, > pivot)
Post-picture
---+---+---+---+---
| < | = | > |
---+---+---+---+---
| | | |
lb s l ub
Invariant
---+---+---+---+---+---
| < | = | ? | > |
---+---+---+---+---+---
| | | | |
lb s i l ub
There are lots of other possibilities
---+---+---+---+---+---
| ? | < | = | > |
---+---+---+---+---+---
| | | | |
lb ub
How much does "Hello" + "Goodbye" take?
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Java 7 API] [Java Code Conventions] [GNU Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2013F (Rebelsky)] [CSC 207 2013S (Walker)] [CSC 207 2011S (Weinman)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)] [Issue Tracker (Textbook)]
Copyright (c) 2013-14 Samuel A. Rebelsky.

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by/3.0/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.