1 CS1110 21 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.

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

Typography: The basic building block of any printed page.
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.
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! Aoccdrnig.
BT101: Hermeneutics Introduction. A. Description of Hermeneutics 1. General Hermeneutics The study of the activity of interpretation;
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,
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.
Vision and Perception Input-Process-Output (S)IPDE Process Time Relevant.
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.
Or fizzix, fizicks, fzzx, etc THE Phun damental science.
Count the Number of “f”s FINISHED FILES ARE THE RE SULT OF YEARS OF SCIENTI FIC STUDY COMBINED WITH THE EXPERIENCE OF YEARS... How many did you find?
Sensation.
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.
Mindboggling. Visual Imagery (visual cortex) Visualize a place you’d like to be. Maybe it’s riding a bike, sitting in the park or just hanging out in.
Technical Reading Presented by Beatrice Moore Luchin NUMBERS Mathematics Professional Development NUMBERSmpd.com.
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. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Communication “ The exchange of information, facts, ideas and meanings” Quinn et al. (2003, p38) Transferring information to bring about change “ The process.
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.
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.
Sensation & Perception
Illusions and Other Visual Defects CITA 6016 Food Sensory Analysis University of Puerto Rico Food Science & Technology.
Ignite your thought process Creativity. Two Myths About Creativity  Only a few special people possess it  Creativity is a gift and not a skill.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid. Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy,
Bible Study for Dummies the Rest of Us I can do this!
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.
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.
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.
Inspiring Youth to Live their Dreams! Scott Shickler Founder & CEO.
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
CS100J Final Class on Classes 22 September 2005
Please read the sign..
The human brain … … tricks us whenever it can!.
CS/ENGRD 2110 Fall 2017 Lecture 5: Local vars; Inside-out rule; constructors
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!
There are 9 people in this picture. Can you find them all?
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
Human factors Age and vision.

Science and the Scientific Method
How does your brain perceive objects?

CS100J Classes, stepwise refinement 21 September 2005
Presentation transcript:

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– Reading for next lecture: the same Today: Pick up: A3 Today’s slides You can do A3 in groups of 2, BUT GROUP EARLY ON CMS 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. Office hours are being held

2

A1 210 out of 211 groups graded at least once 79 out of 210 are done! Please respond to your feedback within 24 hours if you can. We want to finish up A1 by the weekend. Make sure you RRequest a RRegrade when you RResubmit. 3 A3: Adding functionality to A1 Due Wednesday, 29 September Keeping class invariant true Use already-written functions Boolean expressions Use of null and testing for it Use of static variables Form groups on the CMS early, well before you submit. A3: graded in conventional way. Submit once and get a grade.

4 The inside-out rule (see p. 83) Code in a construct can reference any of the names declared or defined in that construct, as well as names that appear in enclosing constructs. (If a name is declared twice, the closer one prevails.) File drawer for class Person Person a0 name getNameAndPop() { return name + PersonPop; } Person a1 name getNameAndPop() { return name + PersonPop; } PersonPop Remember frame boxes and figuring out variable references?

5 Method parameters participate in the inside-out rule: remember the frame. setName(String n) { name= n; } Person a0 name setName(String name) { name= name; } Person a1 name Parameter n would be found in the frame for the method call. Parameter name “blocks” the reference to the field name. Doesn’t work right

6 A solution: this and super Within an object, this evaluates to the name of the object. File drawer for class Person PersonPop setName(String name) { this.name= name; } Person a0 name setName(String name) { this.name= name; } Person a1 name In folder a0, this refers to a0 In folder a1, this refers to a1

7 About super Within a subclass object, super refers to the partition above the one that contains super. toString() { … } otherMethod { … … super.toString() … } Object a1 Elephant method equals() method toString() Because of the keyword super, this calls toString in the Object partition.

8 Strings are (important) objects that come with useful methods. String s= "abc d"; abc d Note the “index (number) from 0” scheme: s as length() charAt(int) substring(int) substring(int, int) indexOf(String) lastIndexOf(String) … String To find specs of methods in String: 1. Visit course website 2. Click Links 3. Click Specs for version Click String in lower left pane s.length() is 5 s.charAt(2) is ‘c’ s.substring(2) is “c d” s.substring(1,3) is “bc”

99 Strings are (important) objects that come with useful methods. String s= "abc d"; abc d Text pp. 175–181 discusses Strings Look in CD ProgramLive Look at API specs for String s.length() is 5 (number of chars) s.charAt(2) is 'c' (char at index 2) s.substring(2,4) is "c " (NOT "c d") s.substring(2) is "c d" " bcd ".trim() is "bcd" (trim beginning and ending blanks) s.indexOf(s1) –index or position of first occurrence of s1 in s (-1 if none) Note the “index (number) from 0” scheme:

10 Strings are objects!!!!!!!!! What is the value of s == t DO NOT USE == TO TEST STRING EQUALITY! s == t tests whether s and t contain the name of the same object, not whether the objects contain the same string. Use s.equals(t) s a1 “lee” … equals(Object) String t a2 “lee” … equals(Object) String

11 Principles and strategies embodied in stepwise refinement 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 specification —before writing its body Separate concerns: focus on one issue at a time Mañana principle: next slide

12 Principles and strategies for reformatting strings When dealing with String, always try to use existing methods!! Ones you have written or those that are in class String Pick out pieces from the input String Build the new String from the Pieces

13 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.