CS/ENGRD 2110 (formerly CS 211) Fall 2009

CS/ENGRD 2110 (formerly CS 211) Fall 2009

THERE IS ROOM IN THE BALCONY! Romeo, Romeo, where art thou! Up in the balcony, where its cheaper! CS/ENGRD 2110 SPRING 2019 Lecture 1: Overview and intro to types http://courses.cs.cornell.edu/cs2110/2019sp CS2110 2 Object-oriented programming, reasoning about

complex problems Testing; Reasoning about correctness Program development Algorithmic complexity, analyzing algorithms, Data structures: linked lists, trees, hash tables, graphs, etc. Programming paradigms: recursion, parallel execution Email from July 2017! 3 Im a rising junior studying I took 2110 in Sp 2016. At the time, I couldnt appreciate everything I was taught and how they were taught I was mostly preoccupied with completing the assignments and passing. But Im starting to realize how terrific a job you and the entire 2110 staff did teaching the material. Im at Verizon as a software engineering intern. Doing JUnit testing has become very routine; it was stressed heavily in 2110. Ive had to use basically all my knowledge of Java and OO programming for my internship, and I can safely say that I would be screwed if I hadnt taken 2110.

While taking 2100, a lot of peers (including myself) were frustrated at how we had to master all the subtle nuances of Java. But now I confidently say that I am so thankful that I know all these concepts. Usefulness of 2110 4 This summer I'm working in particle physics, making simulations of some of the background signal wed expect to see in our detector for an experiment run in the particle accelerator. What I'm working on a clustering algorithm to put together energy depositions from several quantized points in the detector to learn what the initial particle's energy and position was. After some thought, I decided the best first sweep over this data would be to do a depth first search starting about a high energy deposition in the calorimeter. It works great, and my PI was very excited about the results! Usefulness of 2110 5 I am working at a startup in Silicon Valley this summer that

does subscription-based financial management and billing among other things. It has been pretty incredible the amount I've learned from your class that relates to this internship and I have definitely decided to pursue computer science (I was initially engineering physics). Is CS2110 right for you? 6 Knowledge of Java not required Only ~30% of you know Java others know Matlab, Python Requirement: comfort with some programming language, on the level of CS1110 (Python based) and CS1112 (Matlab based). Prior knowledge of OO not required. We assume you do not know Java! If you know Java, the first 3 weeks will be easier for you but you STILL have to learn things, probably unlearn some things, too!

Welcome to CS2110! OO Programming and Data Structures 7 405 158 058 031 039 025 Freshmen Sophomores Juniors Seniors Meng/Masters PhD 716 Total

As of Fri evening, 18 Jan Instructors: Michael Clarkson David Gries Recitation leaders (TAs): 23 Consultants: 21 Letter grade: 688 S/U grade: 22 AUDIT: 6 Lectures 8 TR 10:10-11am, Statler auditorium

Attendance mandatory ENGRD 2110 or CS 2110? Same course! We call it CS 2110 in online materials Non-engineers sign up for CS 2110 Engineers should sign up for ENGRD 2110 Sections (Recitations) 9 T 12:20 T 1:25 T 2:30 T 3:35 W 12:20

W 01:25 W 02:30 W 07:30 4 sections: 2 sections: 2 sections: 2 section: 3 sections: 3 sections: 2 sections: 1 section: Some time EARLY, visit StudentCenter

and change your section to even out the numbers Attendance mandatory Sometimes flipped: you watch videos beforehand, come to recitation and do something Sometimes review, help on homework, new material No permission needed to switch sections, but do register for whichever one Recitation this week 10 Eclipse essentials

Practice with common types DO BEFOREHAND: o Install Java, Eclipse, DrJava (optional) o Watch tutorials on API & String Coursework 11 78 programming assignments (37%) Two prelims (14% and 16%) Final exam (30%) Course evaluation (1%) Work in recitations (1-3%) Formula will change as course progresses and we make changes in assignments, give quizzes, etc. Exams are most important aspect in determining final grade Assignments: a real learning experience 12

Teams of one or two A0 and then A1 will be posted soon on the CMS Finding a partner: choose your own or contact your TA. Piazza can be helpful. One way to do an assignment: Wait until the day before it is due. Result: Frustration, anger, impatience, long lines in consulting room. No fun. Not a good educational experience Assignments: a real learning experience 13 One way to do an

assignment: Read the handout immediately. Work on it every (other) day. Ponder. Look things up. Get help in consulting room, with no lines, or Piano office lessons: hours. Fun, hard Practice Daily?learning work, a great Or put off experience practicing until an hour before weekly lesson? Academic Integrity Trust but verify! 14

99% of you are honest and dont try to cheat We use artificial intelligence tools to check some assignments, so catch the other 1% The software is accurate! It tests your code and notices similarities between code written by different people Sure, you can fool this software but its easier to just do the assignments and if you try to fool it and screw up, you might fail the assignment or even the whole course. Resources 15

JavaHyperText. Course website: Link on Links or Resources page http://www.cs.cornell.edu/courses/JavaAndDS/defini tions.html Java resource: online materials at Oracle JDK web site https://docs.oracle.com/javase/8/docs/api/index.ht ml?java/lang/Object.html Piazza 16 Click link on our links web page to register Incredible resource for 24 x 7 help with anything

We keep an eye on it and answer questions. YOU can (and will) too. Visit the Piazza often. CS2111 17 An enrichment course Help students who might feel overwhelmed by CS2110

Gives more explanation of core ideas behind Java, programming, data structures, assignments, etc. Taught by Bracy, Gries, and a TA, 1 credit S/U Only for students who also take CS2110 Only requirement: Attend weekly lecture I would just like to thank you for taking the time to hold CS2111 this year. You have no idea how the class helped and impacted a lot of us. I would never had "survived" CS2110 without your generous share of your knowledge. I appreciated your time. Obtaining Java and Eclipse 18 Follow instructions on our Resources web page Make sure you have Java JDK 1.8, if not download and install. We explain how on the web page.

Then download and install the Eclipse IDE Test it out: launch Eclipse and click new>Java Project This is one of a few ways Java can be used When program runs, output is visible in a little console window DrJava IDE 19 IDE: Integrated Development Environment DrJava is a much simpler IDE, few features We use it only to demo Java features and programming concepts. Has an interactions pane, which allows trying things without

requiring a complete Java program. Great tool! DONT use it for course assignments use Eclipse Download jar file from links page of course website Homework! 20 Homework 1. Read article Why Software is So Bad. Link: Course website -> Lectures notes (Lecture 1) Homework 2. Get Java, Eclipse, DrJava on your computer. Homework 3. Spend some time perusing the course website. Look at course information, resources, links, etc. Homework 4. BEFORE EACH LECTURE/RECITATION: download pdf form of the slides, bring to class and look at them during lecture. We project not only PPT but also Eclipse and other things. Having PPT slides in paper form or on your laptop/tablet can help you during the lecture. Assignment A0 21

Introduction to Java, Eclipse, and the assert statement Due 123123123123 January at 11:59pm Submit on CMS 22 Relevant JavaHyperText Entries 23 type primitive type type, strong versus weak typing cast function function call

procedure procedure call variable variable declaration expression assignment statement unicode Type: Set of values together with operations on them. 24 Type integer: Can represent values: , 3, 2, 1, 0, 1, 2, 3, them in many ways operations: +, , *, /, unary decimal, binary, octal, maybe as strokes ||||

(thats 4) Do you know how your computer represents Type: Set of values together with operations on them. 25 Java Type int: b % c : remainder when b is divided by c. values: 231 .. 2311 67 % 60 = 7 operations: +, , *, /, %, unary teger.MAX_VALUE: name for max int value: 2311: 21474836 What do you think happens when Integer.MAX_VALUE + 1 is evaluated?.

Talk to neighbors about possibilities. Know Java? designers decided on this Principle: KEEPJava QUIET primitive operations on type int should yield an int. About int Java Principle: A basic operation of int: values: 231 .. 2311, i.e. type int must operations: +, , *, /, %, unary produce an int teger.MAX_VALUE: name for max int value: 2311: 21474836 teger.MAX_VALUE + 1 is 231: 2147483648 WRAP-AROUN 26 Types in Java 27

Primitive Types Fully integrated into Java We'll cover these today! Classes We'll talk about these on Thursday Most-used primitive types 28 int: values: 231 .. 2311 operations: +, , *, /, %, unary double: values like : 22.51E6, 24.9

operations: +, , *, /, %, unary char: values like : 'V' '$' '\n' operations: none boolean: values: true false operations: ! (not), && (and), || (or) b % c : remainder when b is divided by c. 67 % 60 = 7 Write values in scientific notation Use single quotes for type char. '\n' is new-line char Cant use integers as booleans! Primitive number types 29 Integer types:

byte 1 byte short int 2 bytes 4 bytes Real types: float double 4 bytes 8 bytes Use these to save space. Have an array of 1,000,000 integers in range 0..7? Use a byte array rather than an int array long 8 bytes

usual operators 22.51E6 24.9 usual operators Dont worry about this in next 7-8 weeks. Use int and double. Type: Set of values together with operations on them. 30 Valid Python sequence: Matlab and Python are weakly x= 100;

typed: x= Hello World; One variable can contain at x= (1, 2, 3, 4, 5 ); different times a number, a string, an Corresponding array, etc. Java Java strongly typed: int x; A variable must be declared One isnt so concerned with x= 100;

before types. it is used and can contain only values of the x= Hello; type with which it is Declaration of x: declared x can contain Illegal only values of assignment: type int Hello is not an Weakly typed versus strongly typed 31 Weakly typed: Shorter programs, generally. Programmer has more freedom, language is more liberal in applying operations to values.

Strongly typed: Programmer has to be more disciplined. Declarations provide a place for comments about variables. More errors caught at compile-time (e.g. its a syntax errorweak and strong typing not Note: to well assign a string to an int variable). defined; literature has several definitions Basic variable declaration 32

32 Declaration: gives name of variable, type of value it can contain int x; Declaration of x, can contain an int value double area; Declaration of area, can contain a double value int[] a; Declaration of a, can contain a pointer to an int array. We explain arrays much later x 5 int

area 20.1 double a int[] Assignment statement 33 33 Much like in other languages need ; at end: = ; int x; x= 10; other code x= x+1;

Have to declare x before assigning to it. int x= 10; other code x= x+1; Can combine declaration with an initializing assignment. Shorthand for a declaration followed by an assignment. Assignment statement type restriction 34 34 Every expression has a type, which depends on its operators and the types of its operands in a natural way. Rule: In x= e; type of e has to be same as or narrower than type of x. Reason: To avoid possibly losing info without the programmer realizing it. double y= 5 + 1;

The value of 5+1 is automatically cast from type int to type double. int x= 75.5 + 1; Illegal: The exp value is of type double. int x= (int) (75.5 + 1); You can cast to int explicitly. 76 will be stored in x. Casting among types 35 35 (int) 3.2 any number type casts double value 3.2 to an int any number

expression may be automatic cast wider narrow byte short int long float double must be explicit cast, may truncate (int) is a unary prefix operator, just like 3 evaluates to 3 (int) 3.2 evaluates to 3 char is a number type! 36 36 char is a number type: (int) 'V'

Unicode repr. in decimal: 86 (char) 86 'V' Unicode: 16-bit char repr. Encodes chars in just about all languages. In java, use hexadecimal (base 16) char literals: '\u0041' is 'A' '\u0042' is 'B' '\u0056' is 'V' '\u0024' is $' '\u0950' is ' Om, the sound of the universe '\u5927' is ' ' is (I think) a transliteration '\u885b' is ' ' of David into Chinese (Da Wei)

See www.unicode.org A function in Matlab, Python, and Java 37 37 function s = sum(a, b) % Return sum of a and b s= a + b; Matlab Python def sum(a, b): """ return sum of a and b""" return a + b Specificatio n: in comment /** return sum of a and b */

before public static double sum(double a, double b) { function return a + b; Declarations of } parameters a return and b type

Recently Viewed Presentations

  • Training Department Class of 2019 Winter Intersessional Brief

    Training Department Class of 2019 Winter Intersessional Brief

    *Marine RECON/MARSOC - New *USMA Cadet Field Training *USMA Cadet Leadership Dev. Training. Tier 3 Internships (Unfunded) *USCGC Eagle. Baltimore-Chesapeake Bay Outward Bound School - New. National . Outdoor Leadership School / NAWN NOLS - New. Northern Tier High Adventure...
  • Day 5  April 17 World War I M.A.I.N.

    Day 5 April 17 World War I M.A.I.N.

    Trench Warfare - trenches were dug along France's eastern border with Germany, it was called the 'Western Front'. Trench Warfare Men dug trenches that were separated by barbed wire and land mines, the killing zone area between them was called...
  • Look at this cover picture and make a

    Look at this cover picture and make a

    rarities. disgrace. gingerly. sagely. incidentally. The Outsiders Intro/Vocabulary. Loo. Look at the picture displayed on the board and make a prediction . about what you think this story is about, write your prediction in the
  • METODOLOGI DESAIN P r o d i D

    METODOLOGI DESAIN P r o d i D

    According to the definition given by the Industrial Designers Society of America (IDSA), industrial design (ID) is the "professional service of creating and developing concepts and specifications that optimize the function, value and appearance of products and systems for the...
  • Christopher Columbus - Home - Gallipolis City Schools

    Christopher Columbus - Home - Gallipolis City Schools

    Facts The king and queen of Spain made Columbus governor because he found them new land. Columbus believed God had singled him out to go on this voyage. Columbus was expected to find something valuable on each of his voyages...
  • BROWN ALGAE Kingdom: Protista Grouped under: Stramenophila (because

    BROWN ALGAE Kingdom: Protista Grouped under: Stramenophila (because

    Choanoflagellate-like cells are also found in other animal phyla; in organisms such as flatworms and rotifers, for instance, choanoflagellate-like cells are found in . flame bulbs. that act as excretory organs. best living examples of what the ancestor of all...
  • Final Exam Review Definition of Archetype  A recurrent

    Final Exam Review Definition of Archetype A recurrent

    The actual poem probably dates from the 8th century (700's) or so, and… The story may be set even earlier, around 500 A.D. There are a lot of Christian references in the poem, but the characters and setting are Pagan…this...
  • Ecclesiastes 3:1-8 - Olsen Park Church of Christ

    Ecclesiastes 3:1-8 - Olsen Park Church of Christ

    Arial Calibri Courier New Wingdings Sample presentation slides(2) White with Courier font for code slides 1_Sample presentation slides(2) 2_Sample presentation slides(2) 3_Sample presentation slides(2) Ecclesiastes 3:1-8 Ecclesiastes 3:1-8 "Redeeming the Time" "Redeeming the Time" "Redeeming the Time" Time Obligations Hosea...