CSC 212 Data Structures - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

CSC 212 Data Structures

Description:

When class 'has' or 'uses' another class. Define field(s) ... Law of Cybernetic Entomology: There is always one more bug. Why would we want to make it harder? ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 15
Provided by: wwwcsCa
Category:

less

Transcript and Presenter's Notes

Title: CSC 212 Data Structures


1
CSC 212 Data Structures
  • Lecture 30
  • Midterm Review

2
Problem of the Day
  • Can you make this equation correct by only moving
    the numbers around
  • 76 24
  • 72 49

3
Composing/Combining Classes
  • When class has or uses another class
  • Define field(s) or local(s) of latter class
  • Do not use extends nor use implements
  • Gives new class all functionality of original
  • More than having or using certain capabilities
  • I have an arm ! I am 5 fingers and a palm
  • I use a fork ! I have 4 silver tines

4
Composing/Combining Classes
  • When class is or includes another
  • Suggests a subclass/superclass relationship
  • Now use extends or implements
  • Gives new class all functionality of original
  • Prevents rewriting methods and automatically
    exposes functionality
  • I am a bird ? I am an animal
  • I am a CSC professor ? I am a geek

5
Interfaces
  • Programming is already hard
  • Law of Cybernetic Entomology
  • There is always one more bug
  • Why would we want to make it harder?
  • I can only remember 3 things at once
  • Want to limit complexity of my life
  • Do not worry about code beyond method I am writing

6
Interfaces
  • Provide total abstraction of implementation
  • Specifies number of public methods
  • Classes must include implementation of every
    method
  • Allows you to use simplified model
  • Forcibly divorced from how it is implemented
  • Similar to how you all use String
  • In my system, takes 1000 lines of code
  • Includes a HashMap!

7
When To Break an Interface
  • Break interface by getting actual class
  • ONLY DO THIS WHEN NECESSARY!
  • Only break what you make!
  • Break interfaces only for objects the class
    creates
  • Better to use methods in interface

8
Writing Debugging Classes
  • Try limiting the amount of code to write
  • Use other methods whenever possible
  • Careful about replacing O(1) operation with O(n)
    method call
  • Remember, writing code is hard
  • Think about ways to simplify process

9
Working With Linked Lists (1)
10
Working With Linked Lists (2)
11
Where We Are
  • All these ADTs are types of Collections
  • Serve similar purpose hold data for processing
  • Collections usually have certain functions
  • Method to add data to Collection
  • Method to remove data from Collection
  • Method to get datum from Collection
  • Method to switch datum from Collection
  • Classes differ in how to access data

12
Where We Are (2)
Sequence
Collection of elementsAccess by rank
Collection of PositionsAccess via next prev
Collections of elementsAccess ends only
Deque
IndexList
PositionList
List
Queue
Stack
13
Where We Are (3)
  • Collections of Entrys
  • Methods are named like IndexList, but
    uses the keys instead of ranks

Map
Dictionary
14
Your Turn
  • Get back into groups and do activity

15
Before Next Lecture
  • Keep up with your reading!
  • Cannot stress this enough
  • Continue Week 12 Assignment
  • Read Programming Assignment 4
  • Prepare for Midterm 2 next Monday
  • Will also be open book, open note
  • Covers from last midterm through this week
Write a Comment
User Comments (0)
About PowerShow.com