Title: CMPUT 301: Lecture 02 Basic concepts of Design and Implementations
1CMPUT 301 Lecture 02 Basic concepts of Design
and Implementations
- Lecturer Martin Jagersand
- Department of Computing Science
- University of Alberta
-
- Notes based on previous courses by
- Ken Wong, Eleni Stroulia
- Zach Dodds, Martin Jagersand
2Goals 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.
3Design 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)
4Abstraction
- Examplessales person, medical patient, etc.
5Abstraction
- 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
6Separation
- 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)
7Interchangeable Implementations
8Interchangeable Implementations
9Separation
- Separation of concerns
- interfaces reveal assumptions
- implementations hide changeable details
- interface contract
- avoid ripple effects
10Design 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
11Programming 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)
Prog. Lang.
Computer
Human ideas
12Evolution of programming languages
- Machine lang
- Imperative (Fortran, c, Pascal)
- Functional (lisp, ML, Haskell)
- Logical (prolog, alf)
- Object Oriented (Smalltalk, c, java)
13Design 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)
14Example Higher order functions
- Concept from functional design paradigms and
mathematics - Qf g
- Implementation in imperative and OO languages and
comments. - (blackboard)
15Example 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)
16Xvision application face tracking
17Xvision 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
18fVision (Yale) Haskell, greencard, c
Example program
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
geometry trackClown v composite2 concat2
(trackEyes v) (trackMouth v)
19fVision (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
20XVision2 (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.
21Next time
- Object oriented design strategies