CS2102 (B12): Object-Oriented Design Concepts
Recap and Practice, Week 3

Home | Staff and Office Hours | Lectures and Assignments | MyWPI | Policies

What Your Should Have Learned In Week 3

During week 3, you should have learned

What You Should Be Able to Do Now (Tests, etc)

Known Confusions from This Week

Interfaces: I know many are still confused about the role of interfaces, and are unsure why they are necessary. Interfaces are a hallmark of good designs. They are not strictly necessary (in that you can write code that produces the right answer without them), but they are critical in practice for writing code that can be maintained over time (what if you need to change the data structure later), and for writing code in large teams (where interfaces summarize what different members of the team can expect from each others' code).

What are ADTs? Many are also still struggling with what an ADT is, and how it differs from a data structure. Generally speaking, an ADT describes data with particular operations and behavior, but does not commit to a concrete implementation; as such, one can't talk about the performance of an ADT. A data structure is a concrete organization of data with concrete implementation of methods; we can talk about the performance of different operations on data structures.

So far, this course has covered 4-5 ADTs: sets, bags (in the notes only), queues, priority queues, and stacks. We have covered 4-5 data structures: lists, sorted lists (implicitly, assuming you saw sorting in a previous CS course), binary trees, BSTs, and AVL trees. We could ask how fast each of the data structures could perform the operations required of each ADT. If you can evaluate the performance, you have a data structure; if you know only how an operation should behave, but don't have a specific algorithm or code for it, you have an ADT.

(To those in my Friday review session: we accidentally classified stacks, queues, and priority queues as data structures on Friday afternoon. They should have been classified as ADTs.)

Terminology for axioms, invariants, and properties: Invariants are about data structures: they capture a data structure requires about data in some core shape (such as what makes a binary tree be a BST). Axioms and properties are about ADTs: the former captures how the operations behave and interact; the latter is more descriptive, to help a programmer understand characteristics of data (such as "no duplicates").