12-originalityisoverrated

12-originalityisoverrated - Originality is Overrated: OO...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Originality is Overrated: OO Design Principles Iterating And Testing Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 — Lecture 12 — 10/01/2009 © University of Colorado, 2009 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lecture Goals: Part One • Object-Oriented Design Principles • Open-Closed Principle • Don’t Repeat Yourself • Single Responsibility Principle • Liskov Substitution Principle • Aggregation and Composition, Revisited • Discuss the examples in Chapter 8 • Emphasize the OO concepts and techniques encountered in Chapter 8 2
Background image of page 2
Lecture Goals: Part Two • Iteration is fundamental • Feature driven development • Use case driven development • Testing is fundamental • Test driven development • Proving yourself to the customer • Programming by Contract • Defensive Programming • Discuss the examples in Chapter 9 • Emphasize the OO concepts and techniques encountered in Chapter 9 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Originality is Overrated • Corollary: “Only Steal from the Best” — various sources • OO A&D has been performed in various forms and in various contexts for nearly 40 years • Over that time, designers have developed a set of principles that ease the task of creating OO designs • If you apply these principles in your own code, you will be “stealing” from • The same is true of Design Patterns 4
Background image of page 4
OO Principles: What We’ve Seen So Far • We’ve seen the following principles in action over the past eight lectures Classes are about behavior • Emphasize the behavior of classes over the data of classes • Don’t subclass for data-related reasons • Encapsulate what varies • Provides info. hiding, limits impact of change, increases cohesion • One reason to change • Limits impact of change, increases cohesion • Code to an Interface • Promotes Fexible AND extensible code • Code applies across broad set of classes, subclasses can be added in a straightforward fashion (including at run-time) 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
New Principles Open-Closed Principle (OCP) • Classes should be open for extension and closed for modiFcation • Don’t Repeat Yourself (DRY) • Avoid duplicate code by abstracting out things that are common and placing those things in a single location • Single Responsibility Principle (SRP) • Every object in your system should have a single responsibility, and all the object’s services should be focused on carrying it out • Liskov Substitution Principle (LSP) • Subtypes must be substitutable for their base types 6
Background image of page 6
Open-Closed Principle • Classes should be open for extension and closed for modiFcation • Basic Idea: • Prevent, or heavily discourage, changes to the behavior of existing classes • especially classes that exist near the root of an inheritance hierarchy • If a change is required, create a subclass and allow it to extend/override the original behavior
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 49

12-originalityisoverrated - Originality is Overrated: OO...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online