CPS 108, Fall 1999 Program Design and Implementation ● Software Design and Implementation ● Language independent principles of design and programming ➤ Object oriented programming and design ➤ design heuristics ➤ good design helps do away with late night Teer-fests, ➤ coupling, cohesion, small functions, small interfaces ... but some late nights are inevitable ➤ design patterns ➤ your toolkit must include mastery of language/programming and design ➤ factories, adapter, MVC aka observer/observable, ... ● Language specific: ● What’s in the course? ➤ C++ and Java, team projects, mastery exams ➤ idioms ➤ team projects can be more and less than the sum of ➤ smart pointers, vectors/arrays, overloaded operators ... their parts ➤ idiosyncracies, idiocies ➤ high-level abstractions, low-level details ➤ must define virtual destructor, stream zoo in Java, ... ➤ patterns, heuristics, and idioms Duke CPS 108 1. 1 Duke CPS 108 1. 2 Administrivia C++ idioms/general concepts ● check website and news regularly ● templates ➤ http://www.cs.duke.edu/courses/cps108/current/ ➤ generic functions/container classes ➤ duke.cs.cps108 ● inheritance ● Grading (see web pages) ➤ design guidelines, benefits, drawbacks ➤ group projects: small, medium, large ● low-level structures ➤ mastery programs (solo or semi-solo endeavors) ➤ C-style arrays and strings compared to standard: STL, ➤ readings and summaries Tapestry ➤ tests ● from C to C++ ● Evaluating team projects, role of TA, UTA, consultants ➤ function pointers, function objects ➤ face-to-face evaluation, early feedback ● build on generalities, transition to Java ● Compiling, tools, environments, Linux ➤ vectors, interfaces, stress general principles ➤ g++ 2.95, Java 2 aka 1.2 1. 3 1. 4 Duke CPS 108 Duke CPS 108
Design Criteria How to code Good design comes from experience, experience comes from bad ● Coding/Implementation goals: design ➤ Make it run Fred Brooks (or Henry Petroski) ➤ Make it right ● Design with goals: ➤ Make it fast ➤ ease of use ➤ Make it small ➤ portability ● spiral design (or RAD or !waterfall or ...) ➤ ease of re-use ➤ what’s the design methodology? ➤ efficiency specification ➤ first to market design ➤ ????? implementation Duke CPS 108 1. 5 Duke CPS 108 1. 6 Design Heuristics: class/program/function Design patterns (see text by Arthur Riel) “... describes a problem which occurs over and over again in our environment, and then describes the core of the solution to ● Coupling that problem, in such a way that you can use this solution a ➤ classes/modules are independent of each other million times over, without ever doing it the same way twice” ➤ goal: minimal, loose coupling Christopher Alexander, quoted in GOF ➤ do classes collaborate and/or communicate? ● Example: iterator ● Cohesion ➤ sequentially access elements of aggregate without ➤ classes/modules capture one abstraction/model exposing representation/implementation ➤ keep things as simple as possible, but no simpler ➤ see DirStream and other classes in libtapestry ➤ goal: strong cohesion (avoid kitchen sink) ➤ heavily used in STL, with pointer like syntax ● The open/closed principle ● Factory ➤ classes/programs: open to extensibility, closed to ➤ virtual constructor, have system that doesn’t depend on modification how items are created 1. 7 1. 8 Duke CPS 108 Duke CPS 108
Pattern Essentials larger group/company issues ● Name see McCarthy, Dynamics of Software Development ➤ good name provides a handle for the pattern, makes it easy ● establish a shared vision to remember and use: vocabulary ➤ what is hyperwag? what can we add? ● Problem ➤ harmonious sense of purpose ➤ when the pattern is applicable, context, criteria to be met, ● develop a creative environment design goals ➤ the more ideas the better, ideas are infectious ● Solution ➤ don’t flip the BOZO bit ➤ design, collaborations, responsibilities, and relationships of the classes/design elements ● scout the future ➤ what’s coming, what’s the next project ● Consequences ➤ what new technologies will affect this project ➤ trade-offs, problems, results from applying pattern: help in evaluating applicability Duke CPS 108 1. 9 Duke CPS 108 1. 10
Recommend
More recommend