Unformatted text preview:

Software Design1.1CPS 108, Fall 2005z Object oriented programming and design, we'll use Java and C++ (at least)¾ Language independent concepts including design patterns, e.g., Model-View-Controller, iterator, factory, strategy, …¾ Design independent concepts, e.g., coupling, cohesion, testing, refactoring, profiling, …z Non OO programming and design, we'll use C++ (and its C-subset)¾ From Java/ArrayList to C++/vector to C/int *¾ From classes to functions, from references to pointersSoftware Design1.2Goals for students in Compsci 108z Adept at solving problems requiring programming¾ Design, test, implement, release, revise, maintainz Reasonably facile with basic Java idioms/libraries¾ How to read the API, knowing what to ignore¾ Basic language features, basic librariesz Basic knowledge of C++ (and C) programming¾ Beyond the old Compsci 100¾ Java-style use of STL, towards advanced?Software Design1.3More goals for 108 studentsz Know patterns catalog, vocabulary and use¾ HFDP rather than GOF (and more TLAs/FLAs)z Experience working in teams¾ How to accommodate team needs, balance against individual needs (and goals)z Comfort in working alone, how to get and use help¾ Peers, UTAs, TA, prof, Internet, …Software Design1.4Administriviaz check website and bulletin board regularly¾ http://www.cs.duke.edu/courses/cps108/current/¾See links to bulletin board and other stuffz Grading (see web pages)¾ group projects: small, medium, large¾ mastery programs (solo or semi-solo endeavors)¾ readings and summaries¾ testsSoftware Design1.5Administrivia (continued)z Evaluating team projects, role of TA, UTA, consultants¾ face-to-face evaluation, early feedbackz Compiling, tools, environments, Linux, Windows, Mac¾ g++ 3.3, 3.4, 4.0?,¾ Java 5 (requires 10.4 on Mac)¾ Eclipse in all environments¾ Command-line tools???Software Design1.6Classes: Review/Overviewz A class encapsulates state and behavior¾ Behavior first when designing a class¾ Information hiding: who knows state/behavior?z State is private; some behavior is public¾ Private/protected helper functions¾ A class is called an object factory, creates lots of instancesSoftware Design1.7How do classes and objects work?z Classes communicate and collaborate¾ Parameters: send and receive¾ Containment: has a reference to¾ Inheritance: is-az Understanding inheritance and interfaces¾ What is polymorphism?¾ When is polymorphism not appropriate?¾ What is an interface in Java, what about C++?Software Design1.8Design CriteriaGood design comes from experience, experience comes from bad designFred Brooks zDesign with goals:¾ ease of use¾ portability¾ ease of re-use¾ efficiency¾ first to market¾ ?????Software Design1.9How to codez Coding/Implementation goals:¾ Make it run¾ Make it right¾ Make it fast¾ Make it smallz spiral design (or RAD or !waterfall or ...)¾ what’s the design methodology?specificationdesignimplementationSoftware Design1.10XP and Refactoring(See books by Kent Beck (XP) and Martin Fowler (refactoring))z eXtreme Programming (XP) is an agile design process¾ Communication: unit tests, pair programming, estimation¾ Simplicity: what is the simplest approach that works?¾ Feedback: system and clients; programs and stories¾ Courage: throw code away, dare to be great/differentz Refactoring¾ Change internal structure without changing observable behavior¾ Don’t worry (too much) about upfront design¾ Simplicity over flexibility (see XP)Software Design1.11Modules, design, coding, refactor, XPz Make it run, make it right, make it fast, make it smallz Do the simplest thing that can possibly work (XP)¾ Design so that refactoring is possible¾ Don’t lose sight of where you’re going, keep change in mind, but not as the driving force [it will evolve]z Refactor: functionality doesn’t change, code does¾ Should mean that new tests aren’t written, just re-run¾ Depends on modularity of code, testing in piecesz What’s a module in Java?¾ Could be a class, a file, a directory, a package, a jar file¾ We should, at least, use classes and packagesSoftware Design1.12Design Heuristics: class/program/function(see text by Arthur Riel)z Coupling¾ classes/modules are independent of each other¾ goal: minimal, loose coupling¾ do classes collaborate and/or communicate?z Cohesion¾ classes/modules capture one abstraction/model¾ keep things as simple as possible, but no simpler¾ goal: strong cohesion (avoid kitchen sink)z The open/closed principle¾ classes/programs: open to extensibility, closed to modificationSoftware Design1.13Eric Raymondz Open source evangelist¾ The Cathedral and the Bazaarhttp://www.catb.org/~esr/writings/cathedral-bazaar/¾ How to construct software“Good programmers know what to write. Great ones know what to rewrite (and reuse).”z How to convince someone that guns are a good idea? Put this sign up:z THIS HOME IS A GUN-FREE ZONESoftware Design1.14David Parnas (ACM fellow)I would advise students to pay more attention to the fundamental ideas rather than the latest technology. The technology will be out-of-date before they graduate. Fundamental ideas never get out of date. However, what worries me about what I just said is that some people would think of Turing machines and Goedel's theorem as fundamentals. I think those things are fundamental but they are also nearly irrelevant. I think there are fundamental design principles, for example structured programming principles, the good ideas in "Object Oriented" programming,


View Full Document

Duke CPS 108 - Lecture Notes

Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?