CPS 108, Fall 2005Goals for students in Compsci 108More goals for 108 studentsAdministriviaAdministrivia (continued)Classes: Review/OverviewHow do classes and objects work?Design CriteriaHow to codeXP and RefactoringModules, design, coding, refactor, XPDesign Heuristics: class/program/functionEric RaymondDavid Parnas (ACM fellow)Software Design1.1CPS 108, Fall 2005Object 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, …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 108Adept at solving problems requiring programmingDesign, test, implement, release, revise, maintainReasonably facile with basic Java idioms/librariesHow to read the API, knowing what to ignoreBasic language features, basic librariesBasic knowledge of C++ (and C) programmingBeyond the old Compsci 100Java-style use of STL, towards advanced?Software Design1.3More goals for 108 studentsKnow patterns catalog, vocabulary and useHFDP rather than GOF (and more TLAs/FLAs)Experience working in teamsHow to accommodate team needs, balance against individual needs (and goals)Comfort in working alone, how to get and use helpPeers, UTAs, TA, prof, Internet, …Software Design1.4Administriviacheck website and bulletin board regularlyhttp ://ww w.cs.duke.edu/c ourses/cps108/c urrent/See links to bulletin board and other stufGrading (see web pages)group projects: small, medium, largemastery programs (solo or semi-solo endeavors)readings and summariestestsSoftware Design1.5Administrivia (continued)Evaluating team projects, role of TA, UTA, consultantsface-to-face evaluation, early feedbackCompiling, tools, environments, Linux, Windows, Macg++ 3.3, 3.4, 4.0?,Java 5 (requires 10.4 on Mac)Eclipse in all environmentsCommand-line tools???Software Design1.6Classes: Review/OverviewA class encapsulates state and behaviorBehavior first when designing a classInformation hiding: who knows state/behavior?State is private; some behavior is publicPrivate/protected helper functionsA class is called an object factory, creates lots of instancesSoftware Design1.7How do classes and objects work?Classes communicate and collaborateParameters: send and receiveContainment: has a reference toInheritance: is-aUnderstanding inheritance and interfacesWhat is polymorphism?When is polymorphism not appropriate?What is an interface in Java, what about C++?Software Design1.8Design Criteria Good design comes from experience, experience comes from bad designFred Brooks Design with goals:ease of useportabilityease of re-useefficiencyfirst to market?????Software Design1.9How to codeCoding/Implementation goals:Make it runMake it rightMake it fastMake it smallspiral 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))eXtreme Programming (XP) is an agile design processCommunication: unit tests, pair programming, estimationSimplicity: what is the simplest approach that works?Feedback: system and clients; programs and storiesCourage: throw code away, dare to be great/diferentRefactoringChange internal structure without changing observable behaviorDon’t worry (too much) about upfront designSimplicity over flexibility (see XP)Software Design1.11Modules, design, coding, refactor, XPMake it run, make it right, make it fast, make it smallDo the simplest thing that can possibly work (XP)Design so that refactoring is possibleDon’t lose sight of where you’re going, keep change in mind, but not as the driving force [it will evolve]Refactor: functionality doesn’t change, code doesShould mean that new tests aren’t written, just re-runDepends on modularity of code, testing in piecesWhat’s a module in Java?Could be a class, a file, a directory, a package, a jar fileWe should, at least, use classes and packagesSoftware Design1.12Design Heuristics: class/program/function(see text by Arthur Riel)Couplingclasses/modules are independent of each othergoal: minimal, loose couplingdo classes collaborate and/or communicate?Cohesionclasses/modules capture one abstraction/modelkeep things as simple as possible, but no simplergoal: strong cohesion (avoid kitchen sink)The open/closed principleclasses/programs: open to extensibility, closed to modificationSoftware Design1.13Eric RaymondOpen source evangelistThe 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).”How to convince someone that guns are a good idea? Put this sign up: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