Design I Today: Overview Practice Design1.f12.ppt CS 121 “Ordering Chaos” “Mike” Michael A....
-
Upload
primrose-morton -
Category
Documents
-
view
215 -
download
0
Transcript of Design I Today: Overview Practice Design1.f12.ppt CS 121 “Ordering Chaos” “Mike” Michael A....
Design IDesign I
Today:Today: Overview Practice
Design1.f12.ppt
CS 121“Ordering Chaos”
“Mike” Michael A. Erlinger
– 2 – CS 121
AdministriviaAdministrivia
Team Blogs being used??Team Blogs being used??
Grading - ReviewGrading - Review
– 3 – CS 121
Due: This WeekDue: This Week
Elicitation ReportElicitation Report
Game Use CasesGame Use Cases
Technology AssessmentTechnology Assessment
PyGamePyGame
Trac, SVNTrac, SVN
PiazzaPiazza
ManagementManagement Weekly meeting notes with link to goal stack This week’s goal stack (in general rework of last week’s), an
updated copy of last week’s
– 4 – CS 121
DesignDesign
PracticesPractices
PrinciplesPrinciples
PatternsPatterns
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?
– 5 – CS 121
cs121 designcs121 design
GameGame
User interfaceUser interface
Software Software
Test planTest plan
This is well underway.
– 6 – CS 121
But what is design?
– 7 – CS 121
Design: the verbDesign: the verb
“Design is the planning that lays the basis for the making.”
-wikipedia
– 8 – CS 121
Design: the nounDesign: the noun
““Blueprint, something intended as a guide for making Blueprint, something intended as a guide for making something else.something else.””
- google define:design
“Features of shape, configuration, pattern, or ornamentation that can be judged by the eye in finished products. “
NASA
– 9 – CS 121
Design: The ProcessDesign: The Process
“Plans are worthless. Planning is priceless.”
-eisenhower
– 10 – CS 121
Design: a la cs121Design: a la cs121
noun: a model that captures the essential properties noun: a model that captures the essential properties of a thingof a thing
verb: the practice of verb: the practice of ““creatingcreating”” a design to solve some a design to solve some problemproblem
– 11 – CS 121
verbs: Model ≠ Designverbs: Model ≠ Design
Requirements models Documentation
project start project end
Design models
what should it do how will it do it how it does it
Design is a creative, problem-solving process!Design models are predictive. NOT RESTRICTIVE
– 12 – CS 121
designdesign
create the pieces to create the picture
– 13 – CS 121
How Do We Go About Design?How Do We Go About Design?
model model
review (critique)review (critique)
repeatrepeat
until everyone is happy “enough”especially in Agile iterative never finished versus TLB
– 14 – CS 121
Iterative DevelopmentIterative Development
In each iteration:In each iteration:• Identify the objectives/goals of the iteration• Design a solution to achieve the objectives• Implement the solution• Test the implementation
we talked about this last time
– 15 – CS 121
Agile requirementsAgile requirementsAt the start of each iteration: At the start of each iteration:
Incorporate new goals (often produced by last iteration)Incorporate new goals (often produced by last iteration)
Remove goals no longer neededRemove goals no longer needed
ReprioritizeReprioritize
Clarify requirements for goals at top of stackClarify requirements for goals at top of stack
Plan iterationPlan iteration
highest priority goal
lowest priority goal
– 16 – CS 121
Iterative DevelopmentIterative Development
In each iteration:In each iteration:
• Identify the objectives of the iteration• Design a solution to achieve the objectives
Model solutionReviewRepeat until good enough
• Implement the solution• Test the implementation
– 17 – CS 121
Agile DesignAgile Design
Balance is a Balance is a Key Team DecisionKey Team Decision
design for now design for later
– 18 – CS 121
Agile DesignAgile Design
design skeleton add meat
early iterations early iterations
…
Do NOT expect to get everything right the first time!!!
– 19 – CS 121
CS121 Project LandmarksCS121 Project Landmarks
alpha beta v1
stable architecture,stable GUI
game for user testing release to customer
– 20 – CS 121
DesignDesign
PracticesPractices
PrinciplesPrinciples
PatternsPatterns
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?
– 21 – CS 121
Forms of ModelsForms of Models
Text (hyperlinked) – might have a document, e.g., Game Text (hyperlinked) – might have a document, e.g., Game Design DocumentDesign Document
Diagrams, charts, graphs – layout the structure, Diagrams, charts, graphs – layout the structure, interaction, etc.interaction, etc.
Prototypes – express design, allow risk evalPrototypes – express design, allow risk eval
Mathematical modelsMathematical models
– 22 – CS 121
Agile ModelsAgile Models
Know your purposeKnow your purpose
Choose the simplest form that works for that purposeChoose the simplest form that works for that purpose
e.g., Math for a physics engine, Layout for UIe.g., Math for a physics engine, Layout for UI
Know when to throw it awayKnow when to throw it away
– 23 – CS 121
Forms of ModelsForms of Models
Text (hyperlinked)Text (hyperlinked)
DiagramsDiagrams, charts, graphs, charts, graphs
Prototypes Prototypes
Mathematical modelsMathematical models
– 24 – CS 121
Unified Modeling LanguageUnified Modeling Language
The UML is a standard language The UML is a standard language for visualizing, specifying, for visualizing, specifying, constructing, and constructing, and documenting the artifacts of documenting the artifacts of a software system.a software system.
– 25 – CS 121
Domain ModelTop Level Design ModelDomain ModelTop Level Design ModelA domain modelA domain model
... in software engineering can be thought of as a ... in software engineering can be thought of as a conceptual model of a domain of interest (problem conceptual model of a domain of interest (problem domain) which describes the various entities, their domain) which describes the various entities, their attributes, roles and relationships plus the attributes, roles and relationships plus the constraints that govern the integrity of the model constraints that govern the integrity of the model elements comprising that problem domain.elements comprising that problem domain.
– 26 – CS 121
Use Cases:Example: Course SchedulingUse Cases:Example: Course Scheduling
• Register for Classes
• Buy Text Books
• Choose Classes
– 27 – CS 121
Domain model:Course SchedulingDomain model:Course Scheduling
CourseCourse Offering
Instructor
StudentTextbookTime Slot
Room
Meeting
Class List
Author
Department College
Major
Building
Semester
uses
written by
– 28 – CS 121
Use Cases and Domain Model:Course SchedulingUse Cases and Domain Model:Course Scheduling
•Choose Classes -- can we realize •Who keeps a list of all courses•Where is the course schedule
•Should the “Registrar” be added
– 29 – CS 121
Domain Model - PacmanDomain Model - Pacman
PlayerPacman
Screen grid
moves
Grid Cell
positioned on
has aType
Level
has a
lives score
– 30 – CS 121
Next Level: Design ModelNext Level: Design ModelMove From Domain Model to Design ModelMove From Domain Model to Design Model
Major classesMajor classes
Responsibility of each classResponsibility of each class
Interactions of classes, i.e., Fan in, Fan outInteractions of classes, i.e., Fan in, Fan out
– 31 – CS 121
Design Model (work in progress)Design Model (work in progress)
PlayerSpriteLivesScoreCurrent cellMove()
Sprite
LevelCells
GameLevel Cell
Blank cell Ghost cell Dot cell
– 32 – CS 121
CRC Cards Technique(Responsibility-Driven Design)CRC Cards Technique(Responsibility-Driven Design)
Informal, non-detailedInformal, non-detailed
Used for group brain-stormingUsed for group brain-storming
End result is a first cut at design modelEnd result is a first cut at design model
Not intended to provide a complete designNot intended to provide a complete design
To start from Domain Model: consider if each To start from Domain Model: consider if each noun should be a class and if each verb noun should be a class and if each verb should be a responsibility of the noun or should be a responsibility of the noun or class to which it belongs.class to which it belongs.
CRC – Class, Responsibility, Collaboration
– 33 – CS 121
Domain DesignDomain Design
CRC cards: design method for OOCRC cards: design method for OO Class Super and Sub classes, if appropriate Responsibilities Collaboration – other classes Author
“Act out use cases”
CRC - Class, Responsibility, Collaboration
– 34 – CS 121
CRC: The Basic IdeaCRC: The Basic Idea
Develop set of index cards. Develop set of index cards.
Each card represents one design class.Each card represents one design class.
A card contains: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
– 35 – CS 121
Format of CRC cardsFormat 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.
– 36 – CS 121
Pacman Move Use CasePacman Move Use Case
Move:Move:
1.1. Player moves Pac Man left, right, up, downPlayer moves Pac Man left, right, up, down
2.2. Pac Man moves to new space Pac Man moves to new space
2a2a Attempted move prohibited by wall, no movementAttempted move prohibited by wall, no movement
3.3. New space is blankNew space is blank
3a.3a. New space has dot but not last dot, 50 points New space has dot but not last dot, 50 points awardedawarded
3b. New space has last dot, 50 points awarded, new 3b. New space has last dot, 50 points awarded, new level startslevel starts
3c. New space has ghost, life decreases by 1, if last 3c. New space has ghost, life decreases by 1, if last life game endslife game ends
– 37 – CS 121
Domain Model: PacmanDomain Model: Pacman
PlayerPacman
Screen grid
moves
Grid Cell
positioned on
has aType
Level
has a
lives score
– 38 – CS 121
Classes from Domain ModelClasses from Domain Model
PlayerPlayer
PacmanPacman
ScoreScore
LivesLives
LevelLevel
Screen gridScreen grid
Grid CellGrid Cell
Cell typeCell type
– 39 – CS 121
Player CRC cardPlayer CRC card
PlayerClass
– 40 – CS 121
Player CRC cardPlayer CRC card
Player super class:
sub-classes:
Super- and Sub-classesif any
– 41 – CS 121
Player CRC cardPlayer CRC card
Move
Remember score
Remember number of lives
Player
Responsibilities
– 42 – CS 121
Player CRC cardPlayer CRC card
Move
Remember score
Remember number of lives
Player
Collaborationscollaborate with ?
– 43 – CS 121
ResponsibilitiesResponsibilities
PlayerPlayer
PacmanPacman
ScoreScore
LivesLives
LevelLevel
Screen gridScreen grid
Grid CellGrid Cell
Cell typeCell type
Maybe Lives and Score should be part of Player Maybe Lives and Score should be part of Player ClassClass
Use Design principles/patterns to decideUse Design principles/patterns to decide
remember current cell, draw self
– 44 – CS 121
ResponsibilitiesResponsibilities
PlayerPlayer
PacmanPacman
ScoreScore
LivesLives
LevelLevel
Screen gridScreen grid
Grid CellGrid Cell
Cell typeCell type
maybe these should be “attributes” of the player class rather than proper
classes…so what DO YOU DO?
– 45 – CS 121
Attribute vs. CollaborationAttribute vs. Collaboration
An object of a class typically has one or more An object of a class typically has one or more attributesattributes..
Attributes have Attributes have valuesvalues that specify or that specify or describe the object.describe the object.
A value might or might not deserve the A value might or might not deserve the distinction of being an object itself.distinction of being an object itself.
A would-be attribute that is object-valued is A would-be attribute that is object-valued is actually a actually a collaborationcollaboration..
– 46 – CS 121
Design Model:How Does move Work?Design Model:How Does move Work?
PlayerSpriteLivesScoreCurrent cellMove()
Sprite
LevelCells
GameLevel
Cellposition
Blank cell Ghost cell Dot cell
– 47 – CS 121
Design Model: How Does move Work?Design Model: How Does move Work?
PlayerSpriteLivesScoreMove()
Sprite
LevelCellsCurrent cell
GameLevel
Cellposition
Blank cell Ghost cell Dot cell
– 48 – CS 121
Design Model: Sometime laterDesign Model: Sometime later
PlayerSpriteLivesScorePositionMove()
Sprite
LevelCells
GameLevel
Cellposition
Blank cell Ghost cell Dot cell
Has a
Is a
– 49 – CS 121
How to decideHow to decide
Design principlesDesign principles
Software design principles represent a set of guidelines Software design principles represent a set of guidelines that helps us to avoid having a bad design. Avoid that helps us to avoid having a bad design. Avoid Rigidity and Fragility; keep it simple, optimize for the Rigidity and Fragility; keep it simple, optimize for the most important tasks, use default values, ..most important tasks, use default values, ..
Design patternsDesign patterns
A design pattern is a general reusable design solution A design pattern is a general reusable design solution to a commonly occurring problem within a given to a commonly occurring problem within a given context in software design – not a finished design, context in software design – not a finished design, but a template for how to solve a problem, e.g., but a template for how to solve a problem, e.g., algorithmsalgorithms
– 50 – CS 121
Design class modelsDesign class models
attributes
responsibilities
Student
ID
registers
name
– 51 – CS 121
Class ModelsClass Models
Our models evolve ...Our models evolve ...
FFrom Abstract to Specificrom Abstract to Specific
data
methods
Student
int ID
void registers()
name
– 52 – CS 121
Class Models: Aggregation/CompositionClass Models: Aggregation/Composition
Student
int IDcourse courseList
void registers()
Course
course ID
“has a”
1,…
– 53 – CS 121
Class Model: InheritanceClass Model: Inheritance
Student
int ID
void registers()
Part Time Student
int ID
void registers()
Full Time Student
int ID
void registers()
– 54 – CS 121
Use Case Realization:Sequence DiagramUse Case Realization:Sequence DiagramFormalize the ‘acting out” of CRC cardsFormalize the ‘acting out” of CRC cards
Student Registrar Course list
register( int classID) course.stillOpen(classID)
true…
– 55 – CS 121
Design ProcessDesign Process
Design classes
implement
Design documents,UML, CRC, etc.
USE CASES
– 56 – CS 121
UMLUML
Capture important classes, responsibilities, Capture important classes, responsibilities, collaborationscollaborations
Often omit unnecessary detail:Often omit unnecessary detail: e.g. helper classes like lists
– 57 – CS 121
Classification of UML 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
– 58 – CS 121
Forms of Design ModelsForms of Design Models
Text (hyperlinked)Text (hyperlinked)
Diagrams, charts, graphsDiagrams, charts, graphs
Prototypes Prototypes
Software (e.g. proofs of concepts)Software (e.g. proofs of concepts)
Mathematical modelsMathematical models
good form for “testing” design
– 59 – CS 121
PrototypesPrototypes
CommunicateCommunicate
“These are the basics of the game…”
– 60 – CS 121
PrototypesPrototypes
CommunicateCommunicate
Resolve technical risksResolve technical risks
“We know how to detect collisions.”
– 61 – CS 121
PrototypesPrototypes
CommunicateCommunicate
Resolve technical risksResolve technical risks
Evaluate/testEvaluate/test
“This is how the screens will look. What do you think?”
– 62 – CS 121
PrototypesPrototypes
CommunicateCommunicate
Resolve technical risksResolve technical risks
Evaluate/testEvaluate/test
Iterative design/development strategyIterative design/development strategy
Never convert to “real” codeNever convert to “real” code
Prototype 1Prototype 0 Prototype n= v.1
…
– 63 – CS 121
Agile Modeling PrinciplesAgile Modeling Principles
Know your purposeKnow your purpose
Choose the simplest form that worksChoose the simplest form that works
Know when to throw it awayKnow when to throw it away
These apply to prototypes
– 64 – CS 121
Prototyping PrinciplesPrototyping Principles
Know your purpose and expected outcomesKnow 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.
– 65 – CS 121
Prototyping PrinciplesPrototyping Principles
Know your purpose and expected outcomesKnow your purpose and expected outcomes
Choose the simplest form that worksChoose the simplest form that works important to trade time for details
UI mockupsstoryboards
– 66 – CS 121
Prototyping PrinciplesPrototyping Principles
Ask a questionAsk a question
Devise a test protocol or metricDevise a test protocol or metric
Choose the simplest form that worksChoose the simplest form that works
software executables(try prototyping tools like Gamemaker and pygame)
– 67 – CS 121
Prototyping PrinciplesPrototyping Principles
Ask a questionAsk a question
Devise a test protocol or metricDevise a test protocol or metric
Choose the simplest form that worksChoose the simplest form that works
Know when to throw it awayKnow when to throw it away more time developing prototype harder to throw out
– 68 – CS 121
Prototyping PrinciplesPrototyping Principles
Ask a questionAsk a question
Devise a test protocol or metricDevise a test protocol or metric
Choose the simplest form that worksChoose the simplest form that works
Know when to Know when to throw it awaythrow it away or or refactorrefactor
change the internal structure without affecting the external behavior
– 69 – CS 121
Mathematical ModelsMathematical Models
Algebraic models: i.e. FPS(# sprites)Algebraic models: i.e. FPS(# sprites)
Combinatoric models: i.e. #winning strategiesCombinatoric models: i.e. #winning strategies
Probabilistic models: Probabilistic models:
i.e. Prob(A wins | weapons of A and B)i.e. Prob(A wins | weapons of A and B)
SimulationSimulation
– 70 – CS 121
How do we go about design?How do we go about design?
model model
review (critique)review (critique)
repeatrepeat
Next time: Formal design reviews
– 71 – CS 121
Next timeNext time
Design reviewsDesign reviews
More Design principlesMore Design principles
– 72 – CS 121
The EndThe End
– 73 – CS 121
The EndThe End
– 74 – CS 121
Domain ModelDomain Model
PlayerPacman
Screen grid
moves
Grid Cell
positioned on
has aType
Level
has a
lives score