Presentation is loading. Please wait.

Presentation is loading. Please wait.

Appreciating OO Design Principles & Patterns Dale Skrien Dept of Computer Science Colby College Waterville, ME 04901

Similar presentations


Presentation on theme: "Appreciating OO Design Principles & Patterns Dale Skrien Dept of Computer Science Colby College Waterville, ME 04901"— Presentation transcript:

1 Appreciating OO Design Principles & Patterns Dale Skrien Dept of Computer Science Colby College Waterville, ME 04901 djskrien@colby.edu

2 Introduction Desirable properties of software ("elegant" software)  correctness  efficiency  reusability  robustness  extensibility  readability  scalability  maintainability

3 Problems Why don’t my students appreciate these properties (except correctness)?  In the past, they were graded only on correctness  They are used to creating use-once-and-throw-away software  They don’t see large enough software systems where these properties really help

4 My Solution An OOD course with the motto: ”Learn to appreciate the elegant way by doing it the hard way first” I give them a sequence of projects building on each other I don’t tell the students what’s coming. I don’t tell the students the elegant way until after they’ve completed each project Massive refactoring is needed for each project if not done elegantly Completely worked examples of the elegant approach are given out initially after they’ve completed each project. Only partially worked elegant solutions are given out later in the course.

5 Grading The grade is based on elegance in resubmitted code, not in initial code  Code that worked but was inelegant was worth little  "Turn in code that send shivers of joy up and down my spine rather than shudders of revulsion"

6 Lectures & Discussion General design principles  encapsulation and information hiding  separation of responsibilities  maximizing cohesion  minimizing coupling  programming to an interface instead of a class  inheritance vs. delegation  Demeter's Law  mutable vs. immutable classes  design patterns

7 Sample Final Project

8 Sequence of Projects Create a Swing window with a “Play” button Add panel in which note bars appear when clicked and which can be played Add dragging/selection/deletion of notes Add a pallet of different instruments Add undo, redo Add cut, copy, paste Add grouping/ungrouping of notes Add file saving & loading using XML Add command-line playing of saved files

9 Design Principles and Patterns Learned Observer pattern Prototype pattern Factory Method pattern Memento pattern Composite pattern MVC Singleton pattern

10 Observations Students' work markedly improved in all respects over the course of the semester Almost uniformly positive student reviews  Liked trying to come up with good design on their own  Liked trying to second guess me  Developed a disgust for ugly code  Liked reworking ugly code examples in class Time-consuming for instructor  Need to grade and then re-grade all projects  Grading the style and design of systems is hard  Need to devote time to code walkthroughs with all teams

11 Conclusions The course successfully introduced OO design principles and patterns  Students learned important principles and patterns  Students appreciated the principles and patterns  Students developed a sense for code elegance

12 Alternate Project Give them a simple language L Have them create an interpreter for L Have them create a pretty-printer for L Have them create a variable-finder for L Design patterns used:  Interpreter  Visitor  Builder  Façade

13 Other project sequences I’ve used Sampled sound composition Solitaire games Enhancing an existing medium-size system JSP and Servlets

14 Where you can download some of these sequences of projects http://www.cs.colby.edu/djskrien/OOD/SkrienOO DProjectsWithSolns.zip MIDI projects Sampled Sound projects Solitaire projects


Download ppt "Appreciating OO Design Principles & Patterns Dale Skrien Dept of Computer Science Colby College Waterville, ME 04901"

Similar presentations


Ads by Google