1 CS1110 Classes, stepwise refinement 12 Feb 2009 Rsrecah on spleilng Aoccdrnig to a rscheearch at Cmabirgde Uinervtisy, it deosn't mttaer in waht oredr.

Slides:



Advertisements
Similar presentations
The human brain … … tricks us whenever it can!. The phenomenal power of the human mind I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg.
Advertisements

Presentations Jeanne LeBron, AMEC Earth & Environmental Student Initiative Mentoring Program Workshop Jan
I hope you like & find the following useful. Please press enter, or click anywhere on the screen to continue. You can navigate from the bottom left hand.
Literacy Strategies – EDUC 5555 May 7 – May 26, 2011 Instructors: Sandi Hemmert and Thom Olsen
1 CS100J Classes, stepwise refinement 25 February 2007 Rsrecah on spleilng Aoccdrnig to a rscheearch at Cmabirgde Uinervtisy, it deosn't mttaer in waht.
CS100J 18 September 2003 Rsrecah on spleilng Aoccdrnig to a rscheearch at Cmabirgde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are,
Java boot camp1 Subclasses Concepts: The subclass and inheritance: subclass B of class A inherits fields and methods from A. A is a superclass of B. Keyword.
CS 1110 Prelim I: Review Session. Exam Info Prelim 1: 7:30–9:00PM, Thursday, 6 October, Statler Auditorium Look at the previous Prelims Arrive early!
CS 1110 Prelim I: Review Session. Introduction My name: Bruno Abrahao – We have four TA’s in the room to help you individually Shuang Zhao Nam Nguyen.
1 CS100J 18 September 2007 More on Methods. Developing methods. Also: The inside-out rule; and the use of this and super. Read sec. 2.5 on stepwise refinement.
1 CS100J 20 September 2005 More on Methods. Developing methods Also: About the use of this and super Read section 2.5 on stepwise refinement Listen to.
What is science? Science: is a process by which we gain knowledge deals only with the natural world collects & organizes information (data/evidence) gives.
Sensation and Perception Chapter 3. Psychophysics This is how we experience our physical world. Classroom demo judging weight of pill bottles. Which one.
Logo Design. UNTITLED Cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mind: aoccdrnig to a rscheearch.
Inclusive Learning Through Technology Damian Gordon.
Neural Networks AI – Week 21 Sub-symbolic AI One: Neural Networks Lee McCluskey, room 3/10
CS/ENGRD 2110 FALL 2013 Lecture 5: Local vars; Inside-out rule; constructors 1.
Sensation.
1 CS1110 Lecture Sept Developing (String-processing) programs; class Vector; wrapper classes Prelim: 7:30-9PM Thursday 7 October. Last name A-K:
T HE H UMAN M IND. The phaonmneal pwer of the hmuan mnid Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deson’t mttaer in what oredr the ltteers.
What do you see?. O lny srmat poelpe can raed tihs. I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor.
Teaching reading.
1 CS Sept 2010 Inside-out rule; use of this, super Developing methods (using Strings). Read sec. 2.5, stepwise refinement Listen to Plive, 2.5.1–2.5.4.
Taxonomy, Ontology, Semantics and Other Painful Things By Francis Hsu
~ Thought Journal ~ SILENTLY read the following passage. When you are finished, SILENTLY write down your reaction in your thought journal. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Editing Documents Dr. Anatoliy Tmanov Pennsylvania State University.
The phenomenal power of the human mind   I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg.The phaonmneal pweor of the hmuan mnid!
Please read this sentence and count the number of F’s:
1 CS100J Classes, stepwise refinement 14 Feb 2007 Rsrecah on spleilng Aoccdrnig to a rscheearch at Cmabirgde Uinervtisy, it deosn't mttaer in waht oredr.
PROOFREADING Mini-lesson (Step 4 of WHAT GOOD WRITERS DO... )
The human brain … … tricks us whenever it can!. The human mind is so non-literal! I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg.
CHS AP Psychology Unit 4: Sensation, Perception and States of Consciousness Essential Task 4-1: Discuss basic principles of sensation/bottom up processing.
Sensation & Perception
Ignite your thought process Creativity. Two Myths About Creativity  Only a few special people possess it  Creativity is a gift and not a skill.
Read each slide for directions
The Eye and Optical Illusions Chatfield Senior High.
1 CS1110 Stepwise refinement, more on classes 24 Sep 2009 Application of String processing and stepwise refinement. Miscellaneous points about classes.
Readability Make sure at least the first and last letter of your word are very readable. If some of the other in between letters must sacrifice their readability.
1 CS1110 Classes, stepwise refinement 17 Feb 2009 Miscellaneous points about classes. More on stepwise refinement. Next: wrapper classes. Section 5.1 of.
1.
Welcome to Group Dynamics LDSP 351 Dr. Crystal Hoyt.
1 CS Sep 2011 Miscellaneous points about classes. More on stepwise refinement. Next: wrapper classes. Section 5.1 of class text Need Help? Make.
1 CS February 2009 Inside-out rule; use of this and super Developing methods (using String ops). Read sec. 2.5 on stepwise refinement Listen to.
Lesson 1-4 Preparing a Chart of Accounts
Inspiring Youth to Live their Dreams! Scott Shickler Founder & CEO.
1 CS1110 Classes, wrapper classes, Vectors. 10 Feb 2012 Miscellaneous points about classes. Discussion of wrapper classes and class Vector Use the text.
Aoccdrnig to rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoatnt tihng is taht the frist.
The human brain … … tricks us whenever it can!.
The phenomenal power of the human mind   I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg The phaonmneal pweor of the hmuan mnid!
Elements of Effective Literacy Instruction in Grades 5-8
CS1110 Classes, stepwise refinement 23 Sep 2009
CS/ENGRD 2110 Spring 2014 Lecture 5: Local vars; Inside-out rule; constructors
CS100J Final Class on Classes 22 September 2005
Please read the sign..
CS/ENGRD 2110 Spring 2016 Lecture 5: Local vars; Inside-out rule; constructors
Even though the next page may look weird, you can still read it!
Unit 4: Sensation & Perception
Science and the Scientific Method
Closing IBS Lecture Fall 2008.
Sensation and Perception
Science and the Scientific Method
Sabotage Effective Communication

Science and the Scientific Method
How does your brain perceive objects?
CS 1110 Prelim I: Review Session Spring 2011

Mining Gold from Data Data Mining.
CS100J Classes, stepwise refinement 21 September 2005
CS100J Final Class on Classes 10 February 2005
Presentation transcript:

1 CS1110 Classes, stepwise refinement 12 Feb 2009 Rsrecah on spleilng Aoccdrnig to a rscheearch at Cmabirgde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is that the frsit and lsat ltteer be at the rghit pclae. The rset can be a total mses and you can sitll raed it wouthit porbelm.Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Miscellaneous points about classes. More on stepwise refinement. Prelim 7:30-9:00 Thursday, 19 Feb., Baker Lab 200 Review session: 1:00-3:00, Sunday, 15 Feb., Philips 101 Next time: Wrapper classes. Read Section 5.1 of class text

ISSA - Google Tech Talk User Experience of Online Advertising Monday 2/16 4:30pm Philips 203 Molly Stevens, head User Experience Researcher, Google Ads Designing and targeting un-intrusive ads that are also useful The future of Online Ads

3 Help: Get it now if you need it!! Call Cindy for an appointment with David Gries. Send Lillian Lee an to get an appointment. See a consultant in the ACCEL Sun, Mon, Tues, Wed, Thurs 4:00pm to 11:00pm. See a TA. Peer tutoring (free). Ask in Olin 167 or visit On click on "student services". On the page that comes up, click on ”Engineering Learning Initiatives (ELI.) in the left column, upper part. Then, click on "peer tutoring" in the left column.

4 Content of this lecture This lecture contains some final miscellaneous points to round out your knowledge of classes and subclasses. There are a few more things to learn after this, but we will handle them much later. Inheriting fields and methods and overriding methods. Sec. 4.1 and 4.1.1: pp. 142–145 Purpose of super and this. Sec , pp. 144–145. More than one constructor in a class; another use of this. Sec , pp. 110–112. Constructors in a subclass —calling a constructor of the super-class. Sec , pp. 147–148.

5 Employee c= new Employee(“Gries”, 1969, 50000); c.toString() a0 Object name “Gries” start 1969 salary 50, getName() setName(String n) … toString() equals(Object) toString() Employee c a0 Which method toString() is called? Overriding rule or bottom-up rule: To find out which is used, start at the bottom of the class and search upward until a matching one is found. Terminology. Employee inherits methods and fields from Object. Employee overrides function toString. Sec. 4.1, page 142 This class is on page 105 of the text.

6 Purpose of super and this this refers to the name of the object in which it appears. super is similar but refers only to components in the partitions above. /** = String representation of this Employee */ public String toString() { return this.getName() + ", year ” + getStart() + ", salary ” + salary; } ok, but unnecessary /** = toString value from superclass */ public String toStringUp() { return super.toString(); } necessary Sec. 4.1, pages a0 Object name “Gries” start 1969 salary 50, getName() setName(String n) {…} toString() toStringUp() { …} equals(Object) toString() Employee

7 A second constructor in Employee Provide flexibility, ease of use, to user /** Constructor: a person with name n, year hired d, salary s */ public Employee(String n, int d, double s) { name= n; start= d; salary= s; } /** Constructor: a person with name n, year hired d, salary 50,000 */ public Employee(String n, int d) { name= n; start= d; salary= 50000; } First constructor Second constructor; salary is always 50,000 /** Constructor: a person with name n, year hired d, salary 50,000 */ public Employee(String n, int d) { this(n, d, 50000); } Another version of second constructor; calls first constructor Here, this refers to the other constructor. You HAVE to do it this way Sec , page 110

8 a0 Object name “Gries” start 1969 salary 10,000 Employee(String, int) toString() getCompensation() toString() … Employee Executive bonus Executive(String, int, double) getBonus() getCompensation() toString() 50,000 Calling a superclass constructor from the subclass constructor public class Executive extends Employee { private double bonus; /** Constructor: name n, year hired d, salary 50,000, bonus b */ public Executive(String n, int d, double b) { super(n, d); bonus= b; } The first (and only the first) statement in a constructor has to be a call to a constructor of the superclass. If you don’t put one in, then this one is automatically used: super(); Principle: Fill in superclass fields first. Sec , page 147

9 Anglicizing an Integer anglicize(“1”) is “one” anglicize(“15”) is “fifteen” anglicize(“123”) is “one hundred twenty three” anglicize(“10570”) is “ten thousand five hundred seventy” /** = the anglicization of n. Precondition: 0 < n < 1,000,000 */ public static String anglicize(int n) { }

10 Principles and strategies Develop algorithm step by step, using principles and strategies embodied in “stepwise refinement” or “top-down programming. READ Sec. 2.5 and Plive p Take small steps. Do a little at a time Refine. Replace an English statement (what to do) by a sequence of statements to do it (how to do it). Refine. Introduce a local variable —but only with a reason Compile often Intersperse programming and testing Write a method specifications —before writing the bodies Separate your concerns: focus on one issue at a time

11 Principles and strategies Mañana Principle. During programming, you may see the need for a new method. A good way to proceed in many cases is to: 1. Write the specification of the method. 2. Write just enough of the body so that the program can be compiled and so that the method body does something reasonable, but no the complete task. So you put off completing this method until another time —mañana (tomorrow) —but you have a good spec for it. 3. Return to what you were doing and continue developing at that place, presumably writing a call on the method that was just “stubbed in”, as we say.