Design Practices Design Practices Principles Patterns How do

  • Slides: 72
Download presentation
Design Practices

Design Practices

Design • Practices • Principles • Patterns How do we go about design and

Design • Practices • Principles • Patterns How do we go about design and what do we produce? What are the characteristics of good design? What are good solutions to common design problems?

cs 121 design • • • Game User interface Software Test plan ++ This

cs 121 design • • • Game User interface Software Test plan ++ This is well underway.

But what is design?

But what is design?

design: the verb “Design is the planning that lays the basis for the making.

design: the verb “Design is the planning that lays the basis for the making. ” -wikipedia

design: the noun “Blueprint, something intended as a guide for making something else. ”

design: the noun “Blueprint, something intended as a guide for making something else. ” - google define: design

“Plans are worthless. Planning is priceless. ” -eisenhower

“Plans are worthless. Planning is priceless. ” -eisenhower

design: the noun “Features of shape, configuration, pattern, or ornamentation that can be judged

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

design a la cs 121 • noun: a model that captures the essential properties

design a la cs 121 • noun: a model that captures the essential properties of a thing • verb: the practice of “creating” a design to solve some problem

verbs: Model ≠ Design Requirements models what should it do project start Design models

verbs: Model ≠ Design Requirements models what should it do project start Design models how will it do it Documentation how is it does it project end Design is a creative, problem-solving process! Design models are predictive.

design create the piece to create the picture

design create the piece to create the picture

how do we go about design? • model • review (critique) • repeat until

how do we go about design? • model • review (critique) • repeat until everyone is happy “enough”

Waterfall Model with feedback Requirements Design Implementation Test

Waterfall Model with feedback Requirements Design Implementation Test

Iterative Development In each iteration: • • we talked about this last time Identify

Iterative Development In each iteration: • • we talked about this last time Identify the objectives of the iteration Design a solution to achieve the objectives Implement the solution Test the implementation

Agile requirements At the start of each iteration: • Incorporate new goals (often produced

Agile requirements At 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

Iterative Development In each iteration: • Identify the objectives of the iteration • Design

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

agile design for now design for later

agile design for now design for later

agile design skeleton early iterations … add meat later iterations don’t expect to get

agile design skeleton early iterations … add meat later iterations don’t expect to get everything right the first time!

CS 121 project landmarks alpha stable architecture, stable GUI beta v 1 game for

CS 121 project landmarks alpha stable architecture, stable GUI beta v 1 game for user testing release to customer

Design • Practices • Principles • Patterns How do we go about design and

Design • Practices • Principles • Patterns How do we go about design and what do we produce? 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

Forms of models • • Text (hyperlinked) Diagrams, charts, graphs Prototypes Mathematical models

Agile models • Know your purpose • Choose the simplest form that works •

Agile models • Know your purpose • Choose the simplest form that works • Know when to throw it away

Forms of models • • Text (hyperlinked) Diagrams, charts, graphs Prototypes Mathematical models GDD

Forms of models • • Text (hyperlinked) Diagrams, charts, graphs Prototypes Mathematical models GDD

Forms of models • Text (hyperlinked) • Diagrams, charts, graphs • Prototypes • Mathematical

Forms of models • Text (hyperlinked) • Diagrams, charts, graphs • Prototypes • Mathematical models

Unified Modeling Language The UML is a standard language for visualizing, specifying, constructing, and

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

Domain model Room Meeting Building Instructor Department Course Offering Course College Major uses Time

Domain model Room Meeting Building Instructor Department Course Offering Course College Major uses Time Slot Textbook written by Semester Author Class List Student

“Domain” model lives score Player moves Pacman Level positioned on has a Screen grid

“Domain” model lives score Player moves Pacman Level positioned on has a Screen grid has a Grid Cell Type

Design model • Major classes • Responsibility of each class • Interactions of classes

Design model • Major classes • Responsibility of each class • Interactions of classes

Design model (work in progress) Player Sprite Lives Score Current cell Move() Game Level

Design model (work in progress) Player Sprite Lives Score Current cell Move() Game Level Sprite Level Cells Cell Blank cell Ghost cell Dot cell

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

Domain Design CRC cards: design method for OO – Class – Responsibilities – Collaboration “Act out use cases”

CRC Cards Technique (Responsibility-Driven Design) • Informal, non-detailed • Used for group brain-storming •

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

The Basic Idea • Develop set of index cards. • Each card represents one

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

Format of CRC cards Class Name super class sub-classes Responsibilities Collaborations ____________ ____________ Limiting

Format of CRC cards Class Name super class sub-classes Responsibilities Collaborations ____________ ____________ Limiting the size of a card is an attempt at preventing the class from becoming too complex.

Pac Man move use case Move: 1. Player moves Pac Man left, right, up,

Pac Man move use case Move: 1. Player moves Pac Man left, right, up, down 2. Pac Man moves to new space 2 a Attempted move prohibited by wall, no movement 3. New space is blank 3 a. New space has dot but not last dot, 50 points awarded 3 b. New space has last dot, 50 points awarded, new level starts 3 c. New space has ghost, life decreases by 1, if last life game ends

“Domain” model lives score Player moves Pacman Level positioned on has a Screen grid

“Domain” model lives score Player moves Pacman Level positioned on has a Screen grid has a Grid Cell Type

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

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

Player CRC card Class Player

Player CRC card Class Player

Player CRC card Player super class: sub-classes: Super- and Sub-classes if any

Player CRC card Player super class: sub-classes: Super- and Sub-classes if any

Player CRC card Player Move Responsibilities Remember score Remember number of lives

Player CRC card Player Move Responsibilities Remember score Remember number of lives

Player CRC card Player Move Remember score Remember number of lives collaborate with ?

Player CRC card Player Move Remember score Remember number of lives collaborate with ? Collaborations

“Domain” model lives score Player moves Pacman Level positioned on has a Screen grid

“Domain” model lives score Player moves Pacman Level positioned on has a Screen grid has a Grid Cell Type

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

Responsibilities • • Player Pacman Score Lives Level Screen grid Grid Cell type remember current cell, draw self

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

Responsibilities • • Player Pacman Score Lives Level Screen grid Grid Cell type maybe these should be “attributes” of the player class rather than proper classes

Attribute vs. Collaboration • An object of a class typically has one or more

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.

Design model: how does move work? Player Sprite Lives Score Current cell Move() Game

Design model: how does move work? Player Sprite Lives Score Current cell Move() Game Level Sprite Cell position Level Cells Blank cell Ghost cell Dot cell

Design model: how does move work? Player Sprite Lives Score Position Move() Game Level

Design model: how does move work? Player Sprite Lives Score Position Move() Game Level Sprite Cell position Level Cells Blank cell Ghost cell Dot cell

Design model: how does move work? Player Sprite Lives Score Move() Game Level Sprite

Design model: how does move work? Player Sprite Lives Score Move() Game Level Sprite Cell position Level Cells Current cell Blank cell Ghost cell Dot cell

How to decide • Design principles • Design patterns

How to decide • Design principles • Design patterns

Design class models name Student attributes ID registers responsibilities

Design class models name Student attributes ID registers responsibilities

Class models Our models evolve. . . name Student data int ID void registers()

Class models Our models evolve. . . name Student data int ID void registers() methods

Class models: aggregation/composition Student int ID course. List void registers() “has a” Course course

Class models: aggregation/composition Student int ID course. List void registers() “has a” Course course ID 1, …

Class model: Inheritance Student int ID void registers() Full Time Student Part Time Student

Class model: Inheritance Student int ID void registers() Full Time Student Part Time Student int ID void registers()

Use case realization: Sequence diagram Student Registrar register( int class. ID) … Course list

Use case realization: Sequence diagram Student Registrar register( int class. ID) … Course list course. still. Open(class. ID) true

Design classes Software classes implement UML documents

Design classes Software classes implement UML documents

UML • Capture important classes, responsibilities, collaborations • Often omit unnecessary detail: – e.

UML • Capture important classes, responsibilities, collaborations • Often omit unnecessary detail: – e. g. helper classes like lists

Classification of UML • User model view – use case diagrams • Structural model

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

Forms of models • • • Text (hyperlinked) Diagrams, charts, graphs good form for

Forms of models • • • Text (hyperlinked) Diagrams, charts, graphs good form for “testing” design Prototypes Software (e. g. proofs of concepts) Mathematical models

Prototypes • Communicate “These are the basics of the game…”

Prototypes • Communicate “These are the basics of the game…”

Prototypes • Communicate • Resolve technical risks “We know how to detect collisions. ”

Prototypes • Communicate • Resolve technical risks “We know how to detect collisions. ”

Prototypes • Communicate • Resolve technical risks • Evaluate/test “This is how the screens

Prototypes • Communicate • Resolve technical risks • Evaluate/test “This is how the screens will look. What do you think? ”

Prototypes • • Communicate Resolve technical risks Evaluate/test Iterative design/development strategy Prototype 0 Prototype

Prototypes • • Communicate Resolve technical risks Evaluate/test Iterative design/development strategy Prototype 0 Prototype 1 … Prototype n = v. 1

Agile modeling principles • Know your purpose • Choose the simplest form that works

Agile modeling principles • Know your purpose • Choose the simplest form that works • Know when to throw it away These apply to prototypes

Prototyping principles • Know your purpose Make concrete your vision for the customer Is

Prototyping principles • Know your purpose Make concrete your vision for the customer Is our core gameplay fun? Is pygame collision detection fast enough?

Prototyping principles • Know your purpose and expected outcomes Make concrete your vision for

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 (50 x 50) in full screen mode.

Prototyping principles • Know your purpose and expected outcomes • Choose the simplest form

Prototyping principles • Know your purpose and expected outcomes • Choose the simplest form that works

Prototyping principles • Know your purpose and expected outcomes • Choose the simplest form

Prototyping principles • Know your purpose and expected outcomes • Choose the simplest form that works UI mockups storyboards

Prototyping principles • Ask a question • Devise a test protocol or metric •

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)

Prototyping principles • • Ask a question Devise a test protocol or metric Choose

Prototyping principles • • Ask a question Devise a test protocol or metric Choose the simplest form that works Know when to throw it away

Prototyping principles • Ask a question • Devise a test protocol or metric •

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

Mathematical Models • Algebraic models: i. e. FPS(# sprites) • Combinatoric models: i. e.

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

how do we go about design? • model • review (critique) • repeat Next

how do we go about design? • model • review (critique) • repeat Next time: Formal design reviews

Next time • Design reviews • Intro to Design principles

Next time • Design reviews • Intro to Design principles