DOC PREVIEW
Duke CPS 100E - Toward understanding data structures

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Toward understanding data structuresWhat can an Object do (to itself)?Objects and valuesObjects, values, classesDavid ParnasParnas on re-inventionDavid Parnas (entry in Wikipedia)What about a 'struct' (plain old data)CPS 1002.1Toward understanding data structuresWhat can be put in a TreeSet?What can be sorted?Where do we find this information?How do we understand the information?What can be put in an ArrayList? Why is this different?What operations exist on an ArrayList?What about an array, or operations done on an ArrayList as opposed to what an ArrayList does to itself?CPS 1002.2What can an Object do (to itself)?http://www.cs.duke.edu/csed/java/jdk1.4/docs/api/index.htmlLook at java.lang.ObjecttoString()Used to print (System.out.println) an object, overriding toString() can result in 'useful' information being printed, also used in String concatenation: String s = x + y;Default is basically a pointer-valueequals()Determines if guts of two objects are the same, must override, e.g., for using a.indexOf(o) in ArrayList aDefault is ==, pointer equalityhashCode()Hashes object (guts) to value for efficient lookupCPS 1002.3Objects and valuesPrimitive variables are boxes think memory location with valueObject variables are labels that are put on boxesString s = new String("genome");String t = new String("genome");if (s == t) {they label the same box}if (s.equals(t)) {contents of boxes the same}stWhat's in the boxes? "genome" is in the boxesCPS 1002.4Objects, values, classesFor primitive types: int, char, double, booleanVariables have names and are themselves boxes (metaphorically)Two int variables assigned 17 are equal with ==For object types: String, Sequence, othersVariables have names and are labels for boxesIf no box assigned, created, then label applied to nullCan assign label to existing box (via another label)Can create new box using newObject types are references or pointers or labels to storageCPS 1002.5David Parnas "For much of my life, I have been a software voyeur, peeking furtively at other people's dirty code. Occasionally, I find a real jewel, a well-structured program written in a consistent style, free of kludges, developed so that each component is simple and organized, and designed so that the product is easy to change. "CPS 1002.6Parnas on re-invention "We must not forget that the wheel is reinvented so often because it is a very good idea; I've learned to worry more about the soundness of ideas that were invented only once. "CPS 1002.7David Parnas (entry in Wikipedia)Module Design: Parnas wrote about the criteria for designing modules, in other words, the criteria for grouping functions together. This was a key predecessor to designing objects, and today's object-oriented design.Social Responsibility: Parnas also took a key stand against the Strategic Defense Initiative (SDI) in the mid 1980s, arguing that it would be impossible to write an application that was free enough from errors to be safely deployed.Professionalism: Parnas became one of the first software engineers to earn a professional engineering license in Canada. He believes that software engineering is a branch of traditional engineering.CPS 1002.8What about a 'struct' (plain old data)We use classes, data/state is private, methods are publicWhy do we have rules? When can they be broken?Why are there both structs and classes in C++?What about helping class, e.g., word and frequency together?We can have one class nested in another, then we don't have to worry so much about encapsulationSee recitation example for creating a Class that can be compared using equality and can be sortedComparable interface must be symmetric with .equalsWhat happens if this isn't the


View Full Document

Duke CPS 100E - Toward understanding data structures

Documents in this Course
Topics

Topics

9 pages

Lecture

Lecture

3 pages

Notes

Notes

2 pages

Hashing

Hashing

19 pages

Lecture

Lecture

59 pages

Lecture

Lecture

6 pages

Lecture

Lecture

4 pages

Lecture

Lecture

20 pages

Lecture

Lecture

12 pages

Lecture

Lecture

12 pages

Lecture

Lecture

7 pages

Lecture

Lecture

8 pages

Lecture

Lecture

10 pages

Lecture

Lecture

4 pages

Notes

Notes

16 pages

Lecture

Lecture

5 pages

Lecture

Lecture

9 pages

Lecture

Lecture

4 pages

Lecture

Lecture

13 pages

Lecture

Lecture

6 pages

Lecture

Lecture

16 pages

Lecture

Lecture

5 pages

Lecture

Lecture

5 pages

Lecture

Lecture

12 pages

Lecture

Lecture

12 pages

Lecture

Lecture

10 pages

Sets

Sets

14 pages

Lecture

Lecture

9 pages

Lecture

Lecture

4 pages

Test 1

Test 1

7 pages

Load more
Download Toward understanding data structures
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Toward understanding data structures and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Toward understanding data structures 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?