72
Design Practices

Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Embed Size (px)

Citation preview

Page 1: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Design Practices

Page 2: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Design

• Practices

• Principles

• Patterns

What are the characteristics of good design?

What are good solutions to common design problems?

How do we go about design and what do we produce?

Page 3: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

cs121 design

• Game

• User interface

• Software

• Test plan

• ++

This is well underway.

Page 4: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

But what is design?

Page 5: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

design: the verb

“Design is the planning that lays the basis for the making.”

-wikipedia

Page 6: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

design: the noun

“Blueprint, something intended as a guide for making something else.”

- google define:design

Page 7: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

“Plans are worthless. Planning is priceless.”

-eisenhower

Page 8: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

design: the noun

“Features of shape, configuration, pattern, or ornamentation that can be judged by the eye in finished products. “

-NASA

Page 9: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

design a la cs121

• noun: a model that captures the essential properties of a thing

• verb: the practice of “creating” a design to solve some problem

Page 10: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

verbs: Model ≠ Design

Requirements models Documentation

project start project end

Design models

what should it do how will it do it how is it does it

Design is a creative, problem-solving process!Design models are predictive.

Page 11: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

design

create the piece to create the picture

Page 12: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

how do we go about design?

• model

• review (critique)

• repeat

until everyone is happy “enough”

Page 13: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Waterfall Model

Requirements

Design

Implementation

Test

with feedback

Page 14: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Iterative Development

In each iteration:• Identify the objectives of the iteration• Design a solution to achieve the objectives• Implement the solution• Test the implementation

we talked about this last time

Page 15: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Agile requirementsAt the start of each iteration: • Incorporate new goals (often produced by last iteration)• Remove goals no longer needed• Reprioritize• Clarify requirements for goals at top of stack• Plan iteration

highest priority goal

lowest priority goal

Page 16: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Iterative Development

In each iteration:• Identify the objectives of the iteration• Design a solution to achieve the objectives

• Model solution• Review• Repeat until good enough

• Implement the solution• Test the implementation

Page 17: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

agile design

design for now design for later

Page 18: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

agile design

design skeleton add meat

early iterations later iterations

don’t expect to get everything right the first time!

Page 19: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

CS121 project landmarks

alpha beta v1

stable architecture,stable GUI

game for user testing release to customer

Page 20: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Design

• Practices

• Principles

• Patterns

What are the characteristics of good design?

What are good solutions to common design problems?

How do we go about design and what do we produce?

Page 21: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Forms of models

• Text (hyperlinked)

• Diagrams, charts, graphs

• Prototypes

• Mathematical models

Page 22: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Agile models

• Know your purpose

• Choose the simplest form that works

• Know when to throw it away

Page 23: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Forms of models

• Text (hyperlinked)

• Diagrams, charts, graphs

• Prototypes

• Mathematical models

GDD

Page 24: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Forms of models

• Text (hyperlinked)

• Diagrams, charts, graphs

• Prototypes

• Mathematical models

Page 25: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Unified Modeling Language

The UML is a standard language for visualizing, specifying, constructing, and documenting the artifacts of a software system.

Page 26: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Domain model

CourseCourse Offering

Instructor

StudentTextbookTime Slot

Room

Meeting

Class List

Author

Department College

Major

Building

Semester

uses

written by

Page 27: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

“Domain” model

PlayerPacman

Screen grid

moves

Grid Cell

positioned on

has aType

Level

has a

lives score

Page 28: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Design model

• Major classes

• Responsibility of each class

• Interactions of classes

Page 29: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Design model (work in progress)

PlayerSpriteLivesScoreCurrent cellMove()

Sprite

LevelCells

GameLevel

Cell

Blank cell Ghost cell Dot cell

Page 30: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Domain Design

CRC cards: design method for OO– Class– Responsibilities– Collaboration

“Act out use cases”

Page 31: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

CRC Cards Technique(Responsibility-Driven Design)

• Informal, non-detailed

• Used for group brain-storming

• End result is a first cut at design model

• Not intended to provide a complete design

Page 32: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

The Basic Idea

• Develop set of index cards. • Each card represents one design class.• A card contains:

– The name of the class.

– The responsibilities of the class.

– Collaborations: other classes with which this class interacts and its responsibilities in the interaction

Page 33: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Format of CRC cards

Responsibilities

___________

___________

____________

Class Namesuper class

sub-classes

Collaborations

____________

____________

____________

Limiting the size of a card is an attempt at preventingthe class from becoming too complex.

Page 34: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Pac Man move use case

Move:1. Player moves Pac Man left, right, up, down2. Pac Man moves to new space 2a Attempted move prohibited by wall, no movement3. New space is blank3a. New space has dot but not last dot, 50 points awarded3b. New space has last dot, 50 points awarded, new level

starts3c. New space has ghost, life decreases by 1, if last life

game ends

Page 35: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

“Domain” model

PlayerPacman

Screen grid

moves

Grid Cell

positioned on

has aType

Level

has a

lives score

Page 36: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Domain classes

• Player• Pacman• Score• Lives• Level• Screen grid• Grid Cell• Cell type

Page 37: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Player CRC card

PlayerClass

Page 38: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Player CRC card

Player super class:

sub-classes:

Super- and Sub-classesif any

Page 39: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Player CRC card

Move

Remember score

Remember number of lives

Player

Responsibilities

Page 40: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Player CRC card

Move

Remember score

Remember number of lives

Player

Collaborationscollaborate with ?

Page 41: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

“Domain” model

PlayerPacman

Screen grid

moves

Grid Cell

positioned on

has aType

Level

has a

lives score

Page 42: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Responsibilities

• Player• Pacman• Score• Lives• Level• Screen grid• Grid Cell• Cell type

remember current cell, draw self

Page 43: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Responsibilities

• Player• Pacman• Score• Lives• Level• Screen grid• Grid Cell• Cell type

maybe these should be “attributes” of the player class rather than proper classes

Page 44: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Attribute vs. Collaboration

• An object of a class typically has one or more attributes.

• Attributes have values that specify or describe the object.

• A value might or might not deserve the distinction of being an object itself.

• A would-be attribute that is object-valued is actually a collaboration.

Page 45: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Design model: how does move work?

PlayerSpriteLivesScoreCurrent cellMove()

Sprite

LevelCells

GameLevel

Cellposition

Blank cell Ghost cell Dot cell

Page 46: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Design model: how does move work?

PlayerSpriteLivesScorePositionMove()

Sprite

LevelCells

GameLevel

Cellposition

Blank cell Ghost cell Dot cell

Page 47: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Design model: how does move work?

PlayerSpriteLivesScoreMove()

Sprite

LevelCellsCurrent cell

GameLevel

Cellposition

Blank cell Ghost cell Dot cell

Page 48: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

How to decide

• Design principles

• Design patterns

Page 49: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Design class models

attributes

responsibilities

Student

ID

registers

name

Page 50: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Class models

Our models evolve ...

data

methods

Student

int ID

void registers()

name

Page 51: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Class models: aggregation/composition

Student

int IDcourse courseList

void registers()

Course

course ID

“has a”

1,…

Page 52: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Class model: Inheritance

Student

int ID

void registers()

Part Time Student

int ID

void registers()

Full Time Student

int ID

void registers()

Page 53: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Use case realization: Sequence diagram

Student Registrar Course list

register( int classID) course.stillOpen(classID)

true…

Page 54: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Design classes Software classes

implement

UML documents

Page 55: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

UML

• Capture important classes, responsibilities, collaborations

• Often omit unnecessary detail:– e.g. helper classes like lists

Page 56: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Classification of UML• User model view

– use case diagrams

• Structural model view– class diagrams

– object diagrams

• Behavioral model view– sequence diagrams

– collaboration diagrams

– state machine diagrams

– activity diagrams

• Implementation model view– component diagrams

• Environment model view– deployment diagrams

Page 57: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Forms of models

• Text (hyperlinked)

• Diagrams, charts, graphs

• Prototypes

• Software (e.g. proofs of concepts)

• Mathematical models

good form for “testing” design

Page 58: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototypes

• Communicate

“These are the basics of the game…”

Page 59: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototypes

• Communicate

• Resolve technical risks

“We know how to detect collisions.”

Page 60: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototypes

• Communicate

• Resolve technical risks

• Evaluate/test

“This is how the screens will look. What do you think?”

Page 61: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototypes

• Communicate

• Resolve technical risks

• Evaluate/test

• Iterative design/development strategy

Prototype 1Prototype 0Prototype n

= v.1…

Page 62: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Agile modeling principles

• Know your purpose

• Choose the simplest form that works

• Know when to throw it away

These apply to prototypes

Page 63: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototyping principles

• Know your purpose

Make concrete your vision for the customerIs our core gameplay fun? Is pygame collision detection fast enough?

Page 64: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototyping principles

• Know your purpose and expected outcomes

Make concrete your vision for the customer. Verbal feedback.

Is our core gameplay fun? User questionnaire.

Is pygame collision detection fast enough? Calculate FPS vs. # sprites (50x50) in full screen mode.

Page 65: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototyping principles

• Know your purpose and expected outcomes

• Choose the simplest form that works

Page 66: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototyping principles

• Know your purpose and expected outcomes

• Choose the simplest form that works

UI mockupsstoryboards

Page 67: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototyping principles

• Ask a question

• Devise a test protocol or metric

• Choose the simplest form that works

software executables(try prototyping tools like Gamemaker and pygame)

Page 68: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototyping principles

• Ask a question

• Devise a test protocol or metric

• Choose the simplest form that works

• Know when to throw it away

Page 69: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Prototyping principles

• Ask a question

• Devise a test protocol or metric

• Choose the simplest form that works

• Know when to throw it away or refactor

change the internal structure without affecting the external behavior

Page 70: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Mathematical Models

• Algebraic models: i.e. FPS(# sprites)• Combinatoric models: i.e. #winning strategies• Probabilistic models:

i.e. Prob(A wins | weapons of A and B)• Simulation

Page 71: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

how do we go about design?

• model

• review (critique)

• repeat

Next time: Formal design reviews

Page 72: Design Practices. Design Practices Principles Patterns What are the characteristics of good design? What are good solutions to common design problems?

Next time

• Design reviews

• Intro to Design principles