josh bloch charlie garrodcharlie/courses/17-214/... · 1/14/2020  · – gradle, travis-ci,...

44
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 17-Oct-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

1 17-214

PrinciplesofSoftwareConstruction: Objects,Design,andConcurrencyPart1:IntroductionCourseoverviewandintroductiontosoftwaredesignJoshBloch CharlieGarrod

Page 2: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

2 17-214

Softwareiseverywhere

Page 3: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

3 17-214

Growthofcodeandcomplexityovertime

Page 4: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

4 17-214

Blackout of 2003 Normal night-time image

Page 5: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

5 17-214

Page 6: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

6 17-214 15-313 Software Engineering

6

Page 7: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

7 17-214

PrinciplesofSoftwareConstruction: Objects,Design,andConcurrencyPart1:IntroductionCourseoverviewandintroductiontosoftwaredesignJoshBloch CharlieGarrod

Page 8: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

8 17-214

binary tree

graph search

sorting

primes

GCD

Page 9: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

10 17-214

PrinciplesofSoftwareConstruction: Objects,Design,andConcurrencyPart1:IntroductionCourseoverviewandintroductiontosoftwaredesignJoshBloch CharlieGarrod

Page 11: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

11 17-214

Objectsintherealworld

Page 12: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

13 17-214

PrinciplesofSoftwareConstruction: Objects,Design,andConcurrencyPart1:IntroductionCourseoverviewandintroductiontosoftwaredesignJoshBloch CharlieGarrod

Page 14: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

19 17-214

It depends?

Page 20: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

22 17-214

Goalofsoftwaredesign

•  Foreachdesiredprogrambehaviorthereareinfinitelymanyprograms–  Whatarethedifferencesbetweenthevariants?–  Whichvariantshouldwechoose?–  Howcanwecreateavariantwithdesiredproperties?

Page 23: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

24 17-214

AtypicalIntroCSdesignprocess

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

Page 25: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

25 17-214

Bettersoftwaredesign

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

•  Propose,considerdesignalternatives–  Makeexplicitdesigndecisions

Page 26: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

26 17-214

Usingadesignprocess

•  Adesignprocessorganizesyourwork•  Adesignprocessstructuresyourunderstanding•  Adesignprocessfacilitatescommunication

Page 27: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

28 17-214

PrinciplesofSoftwareConstruction: Objects,Design,andConcurrencyPart1:IntroductionCourseoverviewandintroductiontosoftwaredesignJoshBloch CharlieGarrod

Page 29: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

29 17-214

Concurrency

•  Roughly:doingmorethanonethingatatime

Page 30: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

30 17-214

Summary:Coursethemes

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

Page 31: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

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,APIdesign,etc.•  SEMinor:http://isri.cmu.edu/education/undergrad

31

Page 32: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

32 17-214

COURSEORGANIZATION

Page 33: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

33 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 34: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

34 17-214

Learninggoals

•  Abilitytodesignandimplementmedium-scaleprograms•  UnderstandingOOprogrammingconcepts&designdecisions•  Proficiencywithbasicqualityassurancetechniquesfor

functionalcorrectness•  Fundamentalsofconcurrency•  Practicalskills

Page 35: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

35 17-214

Coursestaff

•  [email protected]

•  CharlieGarrod

[email protected]

•  Teachingassistants:Ari,Alice,Daniel,Grace,Henry,Jeremy,Rosie,Shruti,

Tan

Page 36: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

36 17-214

Coursestaff

•  [email protected]

•  CharlieGarrod

[email protected]

•  Teachingassistants:Ari,Alice,Daniel,Grace,Henry,Jeremy,Rosie,Shruti,

Tan

Page 37: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

37 17-214

Coursemeetings

•  Lectures:TuesdayandThursday,3:00–4:20pm,DHA302–  Electronicdevicesdiscouraged

•  Recitations:Wednesdays9:30-…-2:20pm–  Supplementarymaterial,hands-onpractice,feedback–  Bringyourlaptop

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

Recitation attendance is required

Smoking Section

Page 38: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

38 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

•  Assignments–  Homework1availabletomorrow

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

Page 39: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

39 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 40: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

40 17-214

Approximategradingpolicy

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

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

Page 41: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

41 17-214

Collaborationpolicy(alsoseethecoursesyllabus)

•  Weexpectyourworktobeyourown–  Youmustclearlyciteexternalresourcessothatwecanevaluateyourown

personalcontributions.

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

–  Alwaysturninanyworkyou'vecompletedbeforethedeadline

•  Weusecheatingdetectiontools•  Youmustsignandreturnacopyofthecollaborationpolicy

beforewewillgradeyourwork:https://goo.gl/CBXKQK

Page 42: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

42 17-214

Latedaypolicy

•  Youmayturnineach*homeworkupto2dayslate•  Youhavefivefreelatedayspersemester

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

Page 43: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

43 17-214

10%quizzesandparticipation

•  Recitationparticipationcountstowardyourparticipationgrade•  Lecturehasin-classquizzes

Page 44: Josh Bloch Charlie Garrodcharlie/courses/17-214/... · 1/14/2020  · – Gradle, Travis-CI, Checkstyle, Spotbugs: Practical development tools • Assignments – Homework 1 available

44 17-214

Summary

•  Softwareengineeringrequiresdecisions,judgment•  Gooddesignfollowsaprocess•  Youwillgetlotsofpracticein17-214!