1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from...

24
1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … Everyone: Everyone: Pick up 3 hand-outs from Pick up 3 hand-outs from back back table table Extra Credit Information Extra Credit Information Today’s Slides Today’s Slides OO Example Hand-out OO Example Hand-out People who still owe me a “Student Experience & People who still owe me a “Student Experience & Equipment” Survey Equipment” Survey Pick up this one-page survey from the Pick up this one-page survey from the floor near the floor near the podium podium Please return it to me as you leave class today Please return it to me as you leave class today
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    214
  • download

    1

Transcript of 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from...

Page 1: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

11

COMP 3000: Class #2 -- 14 Jan 2003Before class starts …COMP 3000: Class #2 -- 14 Jan 2003Before class starts …

Everyone:Everyone: Pick up 3 hand-outs from Pick up 3 hand-outs from back tableback table

Extra Credit InformationExtra Credit Information Today’s SlidesToday’s Slides OO Example Hand-outOO Example Hand-out

People who still owe me a “Student Experience & Equipment” People who still owe me a “Student Experience & Equipment” SurveySurvey Pick up this one-page survey from the Pick up this one-page survey from the floor near the podiumfloor near the podium Please return it to me as you leave class todayPlease return it to me as you leave class today

Page 2: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

22

COMP 3000: Class #2 OverviewCOMP 3000: Class #2 Overview

AnnouncementsAnnouncements Finish OO Concepts DiscussionFinish OO Concepts Discussion

with class diagrams on ELMOwith class diagrams on ELMO with pseudocode to emphasize value of OOwith pseudocode to emphasize value of OO

Then, if time permits ... Then, if time permits ... QUICK review of a few key computer conceptsQUICK review of a few key computer concepts Start discussing C++ syntaxStart discussing C++ syntax

Page 3: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

33

COMP 3000: Class #3 OverviewCOMP 3000: Class #3 Overview

Call rollCall roll AnnouncementsAnnouncements Continue with C++ syntax discussionContinue with C++ syntax discussion

Look at (more) code examples Look at (more) code examples Review Review Jeanne’s Focus/Warning ListJeanne’s Focus/Warning List

Demo Development EnvironmentDemo Development Environment Assign Program #1Assign Program #1

Recall only 5% => not very big!Recall only 5% => not very big! Expect to use I/O, variables, and a few control constructsExpect to use I/O, variables, and a few control constructs

Page 4: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

44

Announcements Announcements

We have a Teaching Assistant!We have a Teaching Assistant! Donghoon KimDonghoon Kim

Office: Shop 1, Room 102Office: Shop 1, Room 102 Will be maintaining WebsiteWill be maintaining Website Was TA for this class last fall !Was TA for this class last fall ! Office Hours: to be announcedOffice Hours: to be announced Office Phone: 844-6321Office Phone: 844-6321 Email: [email protected]: [email protected]

Page 5: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

55

My Info -- UpdatesMy Info -- Updates

My home email is up and running; OK to use it!My home email is up and running; OK to use it! On syllabus: On syllabus: [email protected]@computer.org

My Auburn email My Auburn email will bewill be [email protected] [email protected] Account “should be up very soon”Account “should be up very soon” Use home email until directed otherwiseUse home email until directed otherwise

My Office Hours:My Office Hours: Added Mon 2-3 p.m.Added Mon 2-3 p.m. May change Tues & Thurs to 4-5 p.m. May change Tues & Thurs to 4-5 p.m.

(so I can address some questions here for you) (so I can address some questions here for you) Might move location of some office hoursMight move location of some office hours

Page 6: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

66

Announcements (cont)Announcements (cont)

GradesGrades ““Standard” Auburn Letter Grading SchemeStandard” Auburn Letter Grading Scheme

Extra Credit -- Yes!Extra Credit -- Yes! Will be added to your Will be added to your completed course averagecompleted course average You may earn <= You may earn <= 10 points10 points You may select from You may select from 14 points of “options”14 points of “options” Details -- see Extra Credit Hand-outDetails -- see Extra Credit Hand-out

Page 7: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

77

Announcements (cont)Announcements (cont)

ExamsExams All in class (1 hr 15 minutes); no take-homeAll in class (1 hr 15 minutes); no take-home You will be allowed to use a “Crib Sheet”You will be allowed to use a “Crib Sheet”

Two sheets of paper, front only (i.e., 2 pages total)Two sheets of paper, front only (i.e., 2 pages total) Must be hand-written, on paper with blue lined backgroundMust be hand-written, on paper with blue lined background Make YOURSELF a photocopy to keep; originals to be handed Make YOURSELF a photocopy to keep; originals to be handed

in with examin with exam NO photocopies allowed to be used during the examNO photocopies allowed to be used during the exam Perfectly legal to work together to design your crib sheetPerfectly legal to work together to design your crib sheet

Recommendation: Start assembling ideas for this WELL Recommendation: Start assembling ideas for this WELL BEFORE the night before the exam … :-)BEFORE the night before the exam … :-)

Page 8: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

88

Announcements (cont)Announcements (cont)

Important Chapter Coverage NotesImportant Chapter Coverage Notes We will not cover every single C++ feature presented We will not cover every single C++ feature presented

in each chapter in class.in each chapter in class. We will discuss the C++ features you MUST knowWe will discuss the C++ features you MUST know

Some features covered in detail in classSome features covered in detail in class Some simple features MENTIONED in class;Some simple features MENTIONED in class;

You will need to learn syntax details from text You will need to learn syntax details from text

WARNING: Some C/C++ features are very likely to WARNING: Some C/C++ features are very likely to cause significant grief for inexperienced programmerscause significant grief for inexperienced programmers Therefore: Therefore: Jeanne’s Focus/Warning ListJeanne’s Focus/Warning List

Page 9: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

99

Jeanne’s Focus/Warning List: Ch 2Jeanne’s Focus/Warning List: Ch 2

Not needed (can be accomplished another way)Not needed (can be accomplished another way) Section 2.14 Section 2.14 forfor Loops Loops Section 2.16 Section 2.16 switchswitch Construct Construct

DANGEROUS to newer programmersDANGEROUS to newer programmers The Conditional operator The Conditional operator ? ? Text Ed 4, p. 78 Text Ed 4, p. 78 Section 2.12Section 2.12 Increment and Decrement Operators Increment and Decrement Operators Section 2.16Section 2.16 switch Construct switch Construct Section 2.18 Section 2.18 break and continue Constructsbreak and continue Constructs

You are permitted to use these -- at your own risk.You are permitted to use these -- at your own risk. You will NOT need them for my exams or pgmg asgmts.You will NOT need them for my exams or pgmg asgmts.

Page 10: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

1010

COMP 3000: Class #2 OverviewCOMP 3000: Class #2 Overview

Call rollCall roll AnnouncementsAnnouncements Finish OO Concepts DiscussionFinish OO Concepts Discussion

with class diagrams on ELMOwith class diagrams on ELMO with pseudocode to emphasize value of OOwith pseudocode to emphasize value of OO

Then, if time permits ... Then, if time permits ... QUICK review of a few key computer conceptsQUICK review of a few key computer concepts Start discussing C++ syntaxStart discussing C++ syntax

Page 11: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

1111

Reminder: Key OO ConceptsReminder: Key OO Concepts

AbstractionAbstraction

InheritanceInheritance of dataof data of operations of operations

PolymorphismPolymorphism Provides an alternative to strict inheritance of the Provides an alternative to strict inheritance of the

superclass’s operationsuperclass’s operation

Page 12: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

1212

Here’s where we stopped:PolymorphismHere’s where we stopped:Polymorphism

Recall: Recall: One One operationoperation; different ; different methods (implementations)methods (implementations) for for

different different subclassessubclasses within same class within same class

Run-time systemRun-time system selects correct method (fcn) while selects correct method (fcn) while program is executing, program is executing, based on data typebased on data type Background: OO software development is highly dependent on use of Background: OO software development is highly dependent on use of

“pointers” -- a “pointers” -- a special kindspecial kind of pointer! of pointer!

Page 13: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

1313

OO -- Overview of Example (red = hand-out; yellow = ELMO)OO -- Overview of Example (red = hand-out; yellow = ELMO)

UML “Class” -- levels of abstractionUML “Class” -- levels of abstraction Student, Professor => Person Student, Professor => Person (leave space @ R)(leave space @ R) PseudocodePseudocode

Report_Name (OPERATION of PERSON) Report_Name (OPERATION of PERSON) Introduce_People_Here (“Main Program”)Introduce_People_Here (“Main Program”)

Add additional kind of Person (TA)Add additional kind of Person (TA) Observe ease of changeObserve ease of change

Add new OBJECTAdd new OBJECT ““Main Program” source code: NO CHANGE!Main Program” source code: NO CHANGE!

Page 14: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

1414

Polymorphism (cont) Polymorphism (cont)

Benefits of PolymorphismBenefits of Polymorphism Add new objects without modifying main program.Add new objects without modifying main program. Facilitates reuse of code from superclasses Facilitates reuse of code from superclasses

when desired when desired Allows programmer to provide different method if Allows programmer to provide different method if

desired desired

Result: Code is easier to maintain!Result: Code is easier to maintain!(So what???)(So what???)

Page 15: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

1515

Polymorphism -- a bit more(not testable; for programmers’ info)Polymorphism -- a bit more(not testable; for programmers’ info)

Operation in superclass => operation available in Operation in superclass => operation available in subclass(es)subclass(es)

METHOD will be METHOD will be inheritedinherited from superclass unless from superclass unless that method is overRIDDEN.that method is overRIDDEN.

Don’t confuse overRIDE with overLOADDon’t confuse overRIDE with overLOAD(next chart -- but NOT testable!)(next chart -- but NOT testable!)

Page 16: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

1616

OverRIDE vs OverLOAD(not testable)OverRIDE vs OverLOAD(not testable)

OverRIDE:OverRIDE: The specific OPERATION will be implemented by a The specific OPERATION will be implemented by a

new METHOD for this particular subclass. new METHOD for this particular subclass. Signature Signature (parameter list) “equivalent.”(parameter list) “equivalent.”

OverLOAD:OverLOAD: Used same NAME for Used same NAME for two DIFFERENT operationstwo DIFFERENT operations! !

(parameter lists /= ) (parameter lists /= )

Page 17: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

1717

COMP 3000: Class #2 OverviewCOMP 3000: Class #2 Overview

Call rollCall roll AnnouncementsAnnouncements Finish OO Concepts DiscussionFinish OO Concepts Discussion

with class diagrams on ELMOwith class diagrams on ELMO with pseudocode to emphasize value of OOwith pseudocode to emphasize value of OO

Then, if time permits ... Then, if time permits ... QUICK review of a few key computer conceptsQUICK review of a few key computer concepts Start discussing C++ syntaxStart discussing C++ syntax

Page 18: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

1818

QUICK Review: Key Computer ConceptsQUICK Review: Key Computer Concepts

Computer Organization Computer Organization Both eds, Sect 1.3, pp. 5-6Both eds, Sect 1.3, pp. 5-6 1. Input1. Input 2. Output2. Output 3. Memory 3. Memory 4. ALU4. ALU 5. CPU5. CPU 6. Secondary Storage6. Secondary Storage

Page 19: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

1919

QUICK Review: Key Computer ConceptsQUICK Review: Key Computer Concepts

What is a computer?What is a computer? Section 1.2Section 1.2

VERY fast computations and logical decisions --VERY fast computations and logical decisions --ONE AT A TIMEONE AT A TIME (so what?) (so what?)

Roughly, what does “700 MHz” mean?Roughly, what does “700 MHz” mean? {Engineers: Right, “computer cycle” != “instruction”}{Engineers: Right, “computer cycle” != “instruction”} Follow (“execute”) instructions in computer programsFollow (“execute”) instructions in computer programs

OK, so what is a computer program?OK, so what is a computer program? VERY Simple: Figure 1.2 VERY Simple: Figure 1.2

Page 20: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

2020

QUICK Review: Key Computer ConceptsQUICK Review: Key Computer Concepts

Program = Series of Instructions to the ComputerProgram = Series of Instructions to the Computer Two Primary ComponentsTwo Primary Components

DataData Data Types (kinds of data needed)Data Types (kinds of data needed) Identifiers (names for variables, constants, etc)Identifiers (names for variables, constants, etc)

InstructionsInstructions Control Structures (why so important?)Control Structures (why so important?) Functions (identifiers also used to name these)Functions (identifiers also used to name these) What else? ___________ & ___________What else? ___________ & ___________

Page 21: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

2121

How do computer programs get built?From Source Code to ExecutableHow do computer programs get built?From Source Code to Executable

Programmer Programmer Text File viaText File via

Editor Editor ““Source code” (what we usually mean by “pgm”) out of editorSource code” (what we usually mean by “pgm”) out of editor

Compiler (perhaps preceded by pre-processor)Compiler (perhaps preceded by pre-processor) Source code in; Object code out of compilerSource code in; Object code out of compiler

Linker/LoaderLinker/Loader Object code in; Executable code out to computerObject code in; Executable code out to computer

Computer follows program Computer follows program (normally including giving results to customer)(normally including giving results to customer)

ELMO vs Fig 1.1 (4 ed: p. 16)ELMO vs Fig 1.1 (4 ed: p. 16)

Page 22: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

2222

QUICK Review: Key Computer ConceptsQUICK Review: Key Computer Concepts

More complicated computer program examplesMore complicated computer program examples Figure 2.7 (4 ed: p. 84)Figure 2.7 (4 ed: p. 84)

There is a very subtle error here …. There is a very subtle error here …. Ideas from more experienced programmers?Ideas from more experienced programmers?

Figure 2.9 (4 ed: p. 89)Figure 2.9 (4 ed: p. 89) Data type solution!Data type solution!

Page 23: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

2323

Crib Sheet RecommendationsCrib Sheet Recommendations

Rules for IdentifiersRules for Identifiers How to declare different types of dataHow to declare different types of data Operators and their precedence: SuggestionsOperators and their precedence: Suggestions

See List of Figures at front of each text See List of Figures at front of each text “ “Precedence and associativity of operators discussed so far”Precedence and associativity of operators discussed so far”

Example: Figure 1.15 in FOURTH Edition, p. 39 Example: Figure 1.15 in FOURTH Edition, p. 39 Figure 1.13Figure 1.13 Figure 2.31Figure 2.31

Syntax for (my required) control structuresSyntax for (my required) control structures

Page 24: 1 COMP 3000: Class #2 -- 14 Jan 2003 Before class starts … ä Everyone: Pick up 3 hand-outs from back table ä Extra Credit Information ä Today’s Slides.

2424

COMP 3000: Class #2 SummaryCOMP 3000: Class #2 Summary

AnnouncementsAnnouncements Finish OO Concepts DiscussionFinish OO Concepts Discussion

with class diagrams on ELMOwith class diagrams on ELMO with pseudocode to emphasize value of OOwith pseudocode to emphasize value of OO

Then, if time permits ... Then, if time permits ... QUICK review of a few key computer conceptsQUICK review of a few key computer concepts Start discussing C++ syntaxStart discussing C++ syntax