josh bloch charlie garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 course meetings •...

45
1 17-214 Principles of Software Construction: Objects, Design, and Concurrency Part 1: Introduction Course overview and introduction to software design Josh Bloch Charlie Garrod

Upload: others

Post on 09-Mar-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

1 17-214

PrinciplesofSoftwareConstruction: Objects,Design,andConcurrencyPart1:IntroductionCourseoverviewandintroductiontosoftwaredesignJoshBloch CharlieGarrod

Page 2: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

2 17-214

Softwareiseverywhere

Page 3: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

3 17-214

Growthofcodeandcomplexityovertime

Page 4: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

4 17-214

Blackout of 2003 Normal night-time image

Page 5: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

5 17-214

Page 6: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

6 17-214 6

Page 7: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

7 17-214

PrinciplesofSoftwareConstruction: Objects,Design,andConcurrencyPart1:IntroductionCourseoverviewandintroductiontosoftwaredesignJoshBloch CharlieGarrod

Page 8: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

8 17-214

binary tree

graph search

sorting

primes

GCD

Page 9: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

9 17-214

Our goal: understanding both the building blocks and the design principles for construction of software systems

Fromprogramstosystems

Writingalgorithms,datastructuresfromscratch

Functionswithinputs

andoutputsSequentialandlocal

computation

Fullfunctionalspecifications

Reuseoflibraries,frameworks

Asynchronousandreactivedesigns

Parallelanddistributed

computationPartial,composable,

targetedmodels

Page 10: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

10 17-214

PrinciplesofSoftwareConstruction: Objects,Design,andConcurrencyPart1:IntroductionCourseoverviewandintroductiontosoftwaredesignJoshBloch CharlieGarrod

Page 11: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

11 17-214

Objectsintherealworld

Page 12: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

12 17-214

Object-orientedprogramming

•  Programmingbasedonstructuresthatcontainbothdataandmethods

publicclassBicycle{privatefinalWheelfrontWheel,rearWheel;privatefinalSeatseat;privateintspeed;…publicBicycle(…){…}publicvoidaccelerate(){speed++;}publicintspeed(){returnspeed;}}

Page 13: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

13 17-214

PrinciplesofSoftwareConstruction: Objects,Design,andConcurrencyPart1:IntroductionCourseoverviewandintroductiontosoftwaredesignJoshBloch CharlieGarrod

Page 14: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

14 17-214

Semesteroverview

•  IntroductiontoJavaandO-O•  Introductiontodesign

–  Designgoals,principles,patterns•  Designingclasses

–  Designforchange–  Designforreuse

•  Designing(sub)systems–  Designforrobustness–  Designforchange(cont.)

•  Designcasestudies•  Designforlarge-scalereuse•  Explicitconcurrency

•  Crosscuttingtopics:–  Moderndevelopmenttools:

IDEs,versioncontrol,buildautomation,continuousintegration,staticanalysis

–  Modelingandspecification,formalandinformal

–  Functionalcorrectness:Testing,staticanalysis,verification

Page 15: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

15 17-214

Sorting with a configurable order, version A

staticvoidsort(int[]list,booleanascending){…booleanmustSwap;if(ascending){mustSwap=list[i]>list[j];}else{mustSwap=list[i]<list[j];}…}

Page 16: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

16 17-214

Sorting with a configurable order, version B interfaceOrder{booleanlessThan(inti,intj);}classAscendingOrderimplementsOrder{publicbooleanlessThan(inti,intj){returni<j;}}classDescendingOrderimplementsOrder{publicbooleanlessThan(inti,intj){returni>j;}}staticvoidsort(int[]list,Orderorder){…booleanmustSwap=order.lessThan(list[j],list[i]);…}

Page 17: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

17 17-214

Sorting with a configurable order, version B'

interfaceOrder{booleanlessThan(inti,intj);}finalOrderASCENDING=(i,j)->i<j;finalOrderDESCENDING=(i,j)->i>j;staticvoidsort(int[]list,Orderorder){…booleanmustSwap=order.lessThan(list[j],list[i]);…}

Page 18: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

18 17-214

Which version is better?

staticvoidsort(int[]list,booleanascending){…booleanmustSwap;if(ascending){mustSwap=list[i]>list[j];}else{mustSwap=list[i]<list[j];}…}

interfaceOrder{booleanlessThan(inti,intj);}finalOrderASCENDING=(i,j)->i<j;finalOrderDESCENDING=(i,j)->i>j;staticvoidsort(int[]list,Orderorder){…booleanmustSwap=order.lessThan(list[j],list[i]);…}

Version A:

Version B':

Page 19: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

19 17-214

It depends?

Page 20: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

20 17-214

Software engineering is the branch of computer science that creates practical, cost-effective solutions to computing and information processing problems, preferably by applying scientific knowledge, developing software systems in the service of mankind.

Software Engineering for the 21st Century: A basis for rethinking the curriculum Manifesto, CMU-ISRI-05-108

Page 21: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

21 17-214

Software engineering is the branch of computer science that creates practical, cost-effective solutions to computing and information processing problems, preferably by applying scientific knowledge, developing software systems in the service of mankind. Software engineering entails making decisions under constraints of limited time, knowledge, and resources…

Engineering quality resides in engineering judgment… Quality of the software product depends on the engineer’s faithfulness to the engineered artifact… Engineering requires reconciling conflicting constraints… Engineering skills improve as a result of careful systematic reflection on experience… Costs and time constraints matter, not just capability…

Software Engineering for the 21st Century: A basis for rethinking the curriculum

Manifesto, CMU-ISRI-05-108

Page 22: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

22 17-214

Goalofsoftwaredesign

•  Foreachdesiredprogrambehaviorthereareinfinitelymanyprograms–  Whatarethedifferencesbetweenthevariants?–  Whichvariantshouldwechoose?–  Howcanwecreateavariantwithdesiredproperties?

Page 23: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

23 17-214

Metricsofsoftwarequality,i.e.,designgoals

Functionalcorrectness Adherenceofimplementationtothespecifications

Robustness Abilitytohandleanomalousevents

Flexibility Abilitytoaccommodatechangesinspecifications

Reusability Abilitytobereusedinanotherapplication

Efficiency Satisfactionofspeedandstoragerequirements

Scalability Abilitytoserveasthebasisofalargerversionoftheapplication

Security Levelofconsiderationofapplicationsecurity

Source: Braude, Bernstein, Software Engineering. Wiley 2011

Page 24: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

24 17-214

AtypicalIntroCSdesignprocess

1.  Discusssoftwarethatneedstobewritten2.  Writesomecode3.  Testthecodetoidentifythedefects4.  Debugtofindcausesofdefects5.  Fixthedefects6.  Ifnotdone,returntostep1

Page 25: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

25 17-214

Bettersoftwaredesign

•  Thinkbeforecoding:broadlyconsiderqualityattributes–  Maintainability,extensibility,performance,…

•  Propose,considerdesignalternatives–  Makeexplicitdesigndecisions

Page 26: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

26 17-214

Usingadesignprocess

•  Adesignprocessorganizesyourwork•  Adesignprocessstructuresyourunderstanding•  Adesignprocessfacilitatescommunication

Page 27: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

27 17-214

Preview:Designgoals,principles,andpatterns

•  Designgoalsenableevaluationofdesigns–  e.g.maintainability,reusability,scalability

•  Designprinciplesareheuristicsthatdescribebestpractices–  e.g.highcorrespondencetoreal-worldconcepts

•  Designpatternscodifyrepeatedexperiences,commonsolutions–  e.g.templatemethodpattern

Page 28: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

28 17-214

PrinciplesofSoftwareConstruction: Objects,Design,andConcurrencyPart1:IntroductionCourseoverviewandintroductiontosoftwaredesignJoshBloch CharlieGarrod

Page 29: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

29 17-214

Concurrency

•  Roughly:doingmorethanonethingatatime

Page 30: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

30 17-214

Summary:Coursethemes

•  Object-orientedprogramming•  Code-leveldesign•  Analysisandmodeling•  Concurrency

Page 31: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

31 17-214

SoftwareEngineering(SE)atCMU

•  17-214:Code-leveldesign–  Extensibility,reuse,concurrency,functionalcorrectness

•  17-313:Humanaspectsofsoftwaredevelopment–  Requirements,teamwork,scalability,security,scheduling,costs,risks,

businessmodels

•  17-413Practicum,17-415Seminar,Internship•  Variouscoursesonrequirements,architecture,software

analysis,SEforstartups,SEforML,APIdesign,etc.•  SEminorandSEconcentration:

–  https://isri.cmu.edu/education/undergrad

Page 32: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

32 17-214

COURSEORGANIZATION

Page 33: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

33 17-214

Thesearenotnormaltimes…

•  Hybridvs.in-personvs.remote•  Overallstudentexperience•  Waitlistissues•  Pre-semestersurvey:https://forms.gle/6okA6utwCsenxXcL8

Page 34: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

34 17-214

Preconditions

•  15-122orequivalent–  Twosemestersofprogramming–  KnowledgeofC-likelanguages

•  21-127or15-151orequivalent–  Familiaritywithbasicdiscretemathconcepts

•  Specifically:–  Basicprogrammingskills–  Basic(formal)reasoningaboutprograms

•  Pre/postconditions,invariants,formalverification–  Basicalgorithmsanddatastructures

•  Lists,graphs,sorting,binarysearch,etc.

Page 35: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

35 17-214

Learninggoals

•  Abilitytodesignandimplementmedium-scaleprograms•  UnderstandingOOprogrammingconcepts&designdecisions•  Proficiencywithbasicqualityassurancetechniquesfor

functionalcorrectness•  Fundamentalsofconcurrency•  Practicalskills

Page 36: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

36 17-214

Coursestaff

•  [email protected]://bit.ly/32J52av

•  CharlieGarrod

[email protected]://bit.ly/3lviI1z

•  Teachingassistants:Alice,Ashley,Daniel,Jiasheng,Michelle,Nathaniel,

Olivia,Valentine,andSean

Page 37: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

37 17-214

Coursestaff

•  [email protected]://bit.ly/32J52av

•  CharlieGarrod

[email protected]://bit.ly/3lviI1z

•  Teachingassistants:Alice,Ashley,Daniel,Jiasheng,Michelle,Nathaniel,

Olivia,Valentine,andSean

Page 38: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

38 17-214

Coursemeetings

•  Lectures:TuesdayandThursday,4:00–5:20pm•  Recitations:Wednesdays10:30am-…-8:30pm

–  Supplementarymaterial,hands-onpractice,feedback–  Bepreparedtoworkonpaperandwithalaptop

•  OfficehoursandZoomlinks:seecoursewebpage–  https://www.cs.cmu.edu/~charlie/courses/17-214/

Synchronous attendance is required unless you have permission for asynchronous attendance

Page 39: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

39 17-214

Infrastructure

•  Coursewebsite:http://www.cs.cmu.edu/~charlie/courses/17-214–  Schedule,officehourscalendar,lectureslides,policydocuments

•  Tools–  Git,Github:Assignmentdistribution,hand-in,andgrades–  Piazza:Discussionboard–  IntelliJorEclipse:Recommendedforcodedevelopment(otherIDEsarefine)–  Gradle,Travis-CI,Checkstyle,SpotBugs:Practicaldevelopmenttools

•  Firstrecitationistomorrow–  IntroductiontoJavaandthetoolsinthecourse–  InstallGit,Java,someIDE,Gradlebeforehand

•  Assignments–  Homework1availabletomorrow

Page 40: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

40 17-214

Textbooks

•  Requiredcoursetextbooks(electronicallyavailablethroughCMUlibrary):–  JoshuaBloch.EffectiveJava,ThirdEdition.

Addison-Wesley,ISBN978-0-13-468599-1.–  CraigLarman.ApplyingUMLandPatterns.3rd

Edition.PrenticeHall,ISBN978-0321356680.

•  Additionalreadingsondesign,Java,andconcurrencyonthecoursewebpage

Page 41: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

41 17-214

Approximategradingpolicy

•  50%assignments•  20%midtermexams(2x10%each)•  20%finalexam•  10%quizzesandparticipation

Thiscoursedoesnothaveafixedlettergradepolicy;i.e.,thefinallettergradeswillnotbeA=90-100%,B=80-90%,etc.

Page 42: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

42 17-214

Collaborationpolicy(alsoseethecoursesyllabus)

•  Weexpectyourworktobeyourown–  Youmustclearlyciteexternalresourcessothatwecanevaluateyourown

personalcontributions.

•  Donotreleaseyoursolutions(notevenafterendofsemester)•  Askifyouhaveanyquestions•  Ifyouarefeelingdesperate,pleasemail/call/talktous

–  Alwaysturninanyworkyou'vecompletedbeforethedeadline

•  Weusecheatingdetectiontools•  Youmustsignandreturnacopyofthecollaborationpolicy

beforewewillgradeyourwork:https://goo.gl/CBXKQK–  UploadsignedcollaborationpolicytoGradescope

Page 43: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

43 17-214

Latedaypolicy

•  Youmayturnineach*homeworkupto2dayslate•  Youhavefivefreelatedayspersemester

–  10%penaltyperdayafterfreelatedaysareused•  Wedon'tacceptwork3dayslate•  Seethesyllabusforadditionaldetails•  Gotextremecircumstances?Talktous

Page 44: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

44 17-214

10%quizzesandparticipation

•  Recitationparticipationcountstowardyourparticipationgrade•  Lecturehasin-classquizzes

–  Ifyouparticipateasynchronously,youmustcomplete"in-class"activitieswithin48hoursofclass

The key to your success in this course is your regular, synchronous engagement with course

activities, staff, and other students

Page 45: Josh Bloch Charlie Garrodcharlie/courses/17-214/2021...2021/02/02  · 17-214 38 Course meetings • Lectures: Tuesday and Thursday, 4:00 – 5:20 pm • Recitations: Wednesdays 10:30

45 17-214

Summary

•  Softwareengineeringrequiresdecisions,judgment•  Gooddesignfollowsaprocess•  Youwillgetlotsofpracticein17-214!