cmput 301: lecture 02 basic concepts of design and implementations lecturer: martin jagersand...
TRANSCRIPT
![Page 1: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/1.jpg)
CMPUT 301: Lecture 02 Basic concepts of Design and
Implementations
Lecturer: Martin JagersandDepartment of Computing Science
University of Alberta
Notes based on previous courses byKen Wong, Eleni Stroulia
Zach Dodds, Martin Jagersand
![Page 2: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/2.jpg)
2
Goals today:
• Concepts and stages in the program designs and implementation process.
• How and why Object Oriented design and Programming evolved and where it fits in the greater picture of SwEng paradigms.
• Some practical OO concepts and examples.
![Page 3: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/3.jpg)
3
Design strategies overview:
• Previous courses: learned pragmatics of programming and principles of algorithms
• This course: Focus on whole project design.• Important concepts:
– abstraction(simplifying to its essentials the description of a real-world entity)
– separation(treating “what” and “how” aspects independently)
![Page 4: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/4.jpg)
4
Abstraction
• Examples:sales person, medical patient, etc.
![Page 5: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/5.jpg)
5
Abstraction
• Design strategy 1:– focus on the essential aspects of an entity or
concept– ignore or conceal non-essentials– map real-world entities to software objects
• Abstraction =– a named collection of attributes (data) and
behavior (actions, methods) relevant to modeling a given entity for some particular purpose
![Page 6: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/6.jpg)
6
Separation
• Design strategy 2:– separate “what” is to be done from “how” it is
done– separate design issues from implementation
details– separate externally “visible” behavior
(interfaces) from hidden, internal mechanisms (implementations)
![Page 7: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/7.jpg)
7
Interchangeable Implementations
![Page 8: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/8.jpg)
8
Interchangeable Implementations
![Page 9: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/9.jpg)
9
Separation
• Separation of concerns:– interfaces reveal assumptions– implementations hide changeable details– interface == contract– avoid ripple effects
![Page 10: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/10.jpg)
10
Design concepts vs.programming languages
• Note that design concepts (e.g. abstraction, separation …) are independent of programming languages
• But one or several programming language may support or impose certain concepts.
Example: Separation: – .h files in c – Definition modules in modula 2,3– Interfaces in java
![Page 11: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/11.jpg)
11
Programming languages
• Programming paradigms and languages are between (and link) human concepts and ideas to machine implementations
• Have changed during time (more so than either ideas or machines)
Computer
Human ideas
Prog.
Lang.
![Page 12: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/12.jpg)
12
Evolution of programming languages
• Machine lang
• Imperative (Fortran, c, Pascal…)
• Functional (lisp, ML, Haskell…)
• Logical (prolog, alf…)
• Object Oriented (Smalltalk, c++, java)
![Page 13: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/13.jpg)
13
Design Strategies vs.programming languages
• Note again that design strategy (e.g. abstraction, separation …) are independent of programming languages.
• Also: The same project can be implemented using different strategies (and languages)
![Page 14: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/14.jpg)
14
Example: Higher order functions
• Concept from functional design paradigms and mathematics
• Q=f g
• Implementation in imperative and OO languages and comments.
(blackboard)
![Page 15: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/15.jpg)
15
Example: XVision
• Provides visual tracking (rmember interaction video in last lecture)
• 10+ years effort several people, several univ• Several implementations, same functionality• Xvision 1-1.3 (Upenn, Yale): c, c++, Imperative• fVision (Yale): Haskell, greencard, c• XVision2 (JHU): c++
(Written using some fvision design strat)
![Page 16: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/16.jpg)
16
Xvision application: face tracking
![Page 17: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/17.jpg)
17
Xvision 1-1.3 (Upenn, Yale): c, c++, Imperative
• Written by “hackers”
• Neat tricks speed up, but shortcut across abstractions
• Good to provide specified functionality,
• but hard to port
• Hard to extend
![Page 18: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/18.jpg)
18
fVision (Yale): Haskell, greencard, c
trackMouth v = bestSSD mouthIms (newsrcI v (sizeof mouthIms))trackLEye v = bestSSD leyeIms (newsrcI v (sizeof leyeIms))trackREye v = bestSSD reyeIms (newsrcI v (sizeof reyeIms))trackEyes v = composite2 (split, join) (trackLEye v) (trackREye v) where split = segToOrientedPts --- some geometry join = orientedPtsToSeg --- some more geometrytrackClown v = composite2 concat2 (trackEyes v) (trackMouth v)
Example program:
![Page 19: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/19.jpg)
19
fVision (Yale): Haskell, greencard, c
• Uses dataflow model, higher order functions
• Much easier to script new behaviours
• Easier to express geometry
• More compact code
• Haskell code about speed: about ¼ of c
![Page 20: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/20.jpg)
20
XVision2 (JHU): c++
• See it in our lab, use in c306, learn in c610!
• Designed first, then implemented
• Extensible, portable
• Some loss of “neat” speadups due to separation and hiding
• Speed: ¼ - 1/7 of original c version.
![Page 21: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes](https://reader036.vdocument.in/reader036/viewer/2022081512/56649e505503460f94b47823/html5/thumbnails/21.jpg)
21
Next time:
• Object oriented design strategies