Upload
felicity-griffith
View
214
Download
0
Embed Size (px)
Citation preview
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 and what do we produce?
cs121 design
• Game
• User interface
• Software
• Test plan
• ++
This is well underway.
But what is design?
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.”
- google define:design
“Plans are worthless. Planning is priceless.”
-eisenhower
design: the noun
“Features of shape, configuration, pattern, or ornamentation that can be judged by the eye in finished products. “
-NASA
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
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.
design
create the piece to create the picture
how do we go about design?
• model
• review (critique)
• repeat
until everyone is happy “enough”
Waterfall Model
Requirements
Design
Implementation
Test
with feedback
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
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
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
design for now design for later
agile design
design skeleton add meat
early iterations later iterations
…
don’t expect to get everything right the first time!
CS121 project landmarks
alpha beta v1
stable architecture,stable GUI
game for user testing release to customer
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?
Forms of models
• Text (hyperlinked)
• Diagrams, charts, graphs
• Prototypes
• Mathematical models
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
Unified Modeling Language
The UML is a standard language for visualizing, specifying, constructing, and documenting the artifacts of a software system.
Domain model
CourseCourse Offering
Instructor
StudentTextbookTime Slot
Room
Meeting
Class List
Author
Department College
Major
Building
Semester
uses
written by
“Domain” model
PlayerPacman
Screen grid
moves
Grid Cell
positioned on
has aType
Level
has a
lives score
Design model
• Major classes
• Responsibility of each class
• Interactions of classes
Design model (work in progress)
PlayerSpriteLivesScoreCurrent cellMove()
Sprite
LevelCells
GameLevel
Cell
Blank cell Ghost cell Dot cell
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
• 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 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
Responsibilities
___________
___________
____________
Class Namesuper class
sub-classes
Collaborations
____________
____________
____________
Limiting the size of a card is an attempt at preventingthe class from becoming too complex.
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
“Domain” model
PlayerPacman
Screen grid
moves
Grid Cell
positioned on
has aType
Level
has a
lives score
Domain classes
• Player• Pacman• Score• Lives• Level• Screen grid• Grid Cell• Cell type
Player CRC card
PlayerClass
Player CRC card
Player super class:
sub-classes:
Super- and Sub-classesif any
Player CRC card
Move
Remember score
Remember number of lives
Player
Responsibilities
Player CRC card
Move
Remember score
Remember number of lives
Player
Collaborationscollaborate with ?
“Domain” model
PlayerPacman
Screen grid
moves
Grid Cell
positioned on
has aType
Level
has a
lives score
Responsibilities
• Player• Pacman• Score• Lives• Level• Screen grid• Grid Cell• Cell type
remember current cell, draw self
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
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?
PlayerSpriteLivesScoreCurrent cellMove()
Sprite
LevelCells
GameLevel
Cellposition
Blank cell Ghost cell Dot cell
Design model: how does move work?
PlayerSpriteLivesScorePositionMove()
Sprite
LevelCells
GameLevel
Cellposition
Blank cell Ghost cell Dot cell
Design model: how does move work?
PlayerSpriteLivesScoreMove()
Sprite
LevelCellsCurrent cell
GameLevel
Cellposition
Blank cell Ghost cell Dot cell
How to decide
• Design principles
• Design patterns
Design class models
attributes
responsibilities
Student
ID
registers
name
Class models
Our models evolve ...
data
methods
Student
int ID
void registers()
name
Class models: aggregation/composition
Student
int IDcourse courseList
void registers()
Course
course ID
“has a”
1,…
Class model: Inheritance
Student
int ID
void registers()
Part Time Student
int ID
void registers()
Full Time Student
int ID
void registers()
Use case realization: Sequence diagram
Student Registrar Course list
register( int classID) course.stillOpen(classID)
true…
Design classes Software classes
implement
UML documents
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 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
• Prototypes
• Software (e.g. proofs of concepts)
• Mathematical models
good form for “testing” design
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
• 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 1Prototype 0Prototype n
= v.1…
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 customerIs our core gameplay fun? Is pygame collision detection fast enough?
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.
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 that works
UI mockupsstoryboards
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 the simplest form that works
• Know when to throw it away
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. #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 time: Formal design reviews
Next time
• Design reviews
• Intro to Design principles