SlideShare a Scribd company logo
1 of 24
Object-Oriented (OO) Design
CSE 5236: Mobile Application Development
Course Coordinator: Dr. Rajiv Ramnath
Instructor: Adam C. Champion, Ph.D.
Reading: Applying UML and Patterns, Chaps. 1, 6
(OO ref.); Big Nerd Ranch Guide, Chap. 2 (Android/MVC)
1
Elements of Good OO Design
• Idea: Capture complexity of real-world problems,
solutions via objects
– Classes and responsibilities
– Polymorphism helps represent the real-world
– Achieve system goals through collaboration
• Principles: Loose coupling, high cohesion
– Abstraction
– Encapsulation, information hiding
• Methodology: Scenario-Driven Design
– Implement objects needed for vertical slices of system
• Technique: CRC-Card-Based Design 2
Terminology Check
• Class
• Object
• Method
• Function
• Class method
• Subclass
(implementation)
• Subtype (interface)
• Interface
• Abstract class
• Virtual method
You should know what each term means!
3
OO Design Process
• Capture narratives of the environment, application (app)
– Via observations, talking with domain experts, stakeholders, end users
– Identify specific “circumstances” where an app would be used
– Capture using text, storyboards, sketches
• Identify domain classes, assign responsibilities; collaborators
• Evaluate using OO Checklist
• Develop the application flow: use cases, screen flows
• Map domain model to Android framework model
• Map app flow to framework model; connect UI to domain
model; identify collaborators, update model/flow
• Add contracts
• Evaluate using OO Checklist (again) 4
Identify Objects and Classes
• Examine nouns, noun phrases as candidates
• Adjectives: candidate attributes or subtypes
• Group into categories: potential abstract classes,
superclasses
• Write down the purpose of each class
• Eliminate redundant or non-domain classes
5
Identify, Assign Responsibilities
• Start with verbs and verb phrases (i.e. actions)
• Assign to the appropriate classes
– Distribute evenly: don’t give one class too much work
– Don’t break the class definition
– Locate responsibility with information
– Locate related information together
6
Map Domain Model to Framework
Patterns
• Usually a variation of MVC
7
Identify Collaborations
• Examine narratives, storyboards, use cases
• Create scenarios
• Walkthrough scenarios
• Identify interactions between classes
– These are the collaborations
8
Evaluate Using Design Checklist
• Each class must have:
– Clear name
– Cohesive description of responsibility
– Long-lived state
– Collaborators
9
Record on CRC Cards (1)
Source: K. Beck and W. Cunningham, “A Laboratory For Teaching Object-Oriented
Thinking,” Proc. ACM OOPSLA, 1989. http://c2.com/doc/oopsla89/paper.html
10
Record on CRC Cards (2)
Sources: K. Beck and W. Cunningham, “A Laboratory For Teaching Object-
Oriented Thinking,” Proc. ACM OOPSLA, 1989; C. Larman, Applying UML
and Patterns, 3rd ed., Addison-Wesley, 2004.
11
Exercise: Tic-Tac-Toe
• Tic-tac-toe, also spelled tick-tack-toe, or noughts and crosses, as it is
known in the UK, Ireland, Australia, New Zealand, is a pencil-and-
paper game for two players, who take turns marking the spaces in a
3×3 grid with the symbols X and O respectively. The X player usually
goes first. The player who succeeds in placing three respective marks
in a horizontal, vertical, or diagonal row wins the game.
• Extend this by adding a narrative about playing the game
on an Android device:
Tic-tac-toe for Android will implement the Tic-tac-toe paper game as
an Android app. In it, human users will be able to play Tic-tac-toe
against the computer. Multiple games may be played in each
session, with either the computer playing first or the human playing
first on an electronic board that will be displayed on the device’s
touch screen. Scores for each session will be accumulated. If the
user quits the session, scores will be reset.
12
Nouns and Verbs
• Nouns: pencil, paper, game, nought, cross, player, X,
O, space, symbol, grid, mark, vertical row, horizontal
row, diagonal row, human user, human, computer,
session, board, touchscreen, score.
(Candidate objects and classes)
• Verbs: take turn, mark, goes, place, win, implement,
play, playing first, display, accumulate, quit, reset.
(Candidate responsibilities)
13
Consolidate: Nouns
• Remove pencil, paper, touchscreen – physical objects
• Symbol and mark identical – retain symbol.
• User vs. player – retain player
• Remove one of board and grid
• Remove touchscreen – physical
• Row is a component
• Session is an instance of game
14
Consolidate: Verbs
• Take turn, goes, play – retain play
• Mark vs. place vs. …? Use place symbol
• Remove implement – irrelevant to game
• Retain display, accumulate, exit and reset
15
Candidate Classes, Responsibilities
• Classes: Symbol, Player, Human,
Computer, Board, Row, and Game (with
attribute Score)
• Instances: O, X of the class Symbol
• Responsibilities: play, place, display,
accumulate (scores), quit, and reset.
16
Allocate Responsibilities to Classes
• Class Game is allocated the responsibilities:
play, accumulateScores, quit, and
reset.
• Class Board has Display responsibilities.
• Class GameGrid has Place.
• Symbol, Player, Human, Computer, and
Row have no responsibilities yet. Keep?
17
Map Domain Model to Framework
Patterns
• Controller classes map to Activities, e.g.
GameSession
• Visual elements (if any, remember we’re
doing domain object design) map to views
• Pure domain objects map to “plain old
Java object” (POJO) hierarchies
18
General Scenario
• Start a new game.
• Determine who plays first: the human or the computer. Assign the X
symbol to the first player; assign the O symbol to the second player.
• The first player places his symbol at an empty location on the board.
The second player does likewise. Repeat until one player has three of
his symbols in a row, column, or diagonal, or no more squares are in
play, in which case the game ends in a draw.
• Accumulate scores for the players. The winning player’s score
increments by 1; the losing player’s score does not change. In a draw,
both players’ scores remain the same.
• If the user wishes, start a new game; else, quit.
19
Screens and
Screen Flows
in Tic-Tac-Toe
20
Scenario Walkthrough – Verification,
Identifying Collaborators
• No class to respond to starting new game.
Create one:
– GameController?
– GameController and Game collaborate
• Symbol creation, placement? Symbol and Board.
• placeSymbol invokes Play?
• Game needs checkResult?
• Board, GameGrid and Game are collaborators.
• Etc.
21
Final Classes, Responsibilities
• Game: Represents a single Tic-Tac-Toe game.
– Responsibilities: play, checkResult
– Collaborators: GameSession, GameView, Grid.
• GameView: Represents the visual display of a Tic-Tac-Toe game.
– Responsibilities: placeSymbol, showScores
– Collaborators: Game
• GameGrid: Represents 3×3 Tic-Tac-Toe grid.
– Responsibilities: placeSymbol, getEmptySquares
– Collaborators: Game
• GameSession: Represents Tic-Tac-Toe play session (multiple games)
– Responsibilities: playNewGame, quit, decidePlayers, accumulateScores
– Collaborators: Game, GameView
• Symbol – represents a Tic-Tac-Toe symbol (i.e., an X or an O)
– Responsibilities: None
– Collaborators: Game 22
Contracts
• Game:
– play(Grid, Symbol, x, y) returns Success, Failure
– checkResultAndSetState(Grid) returns nothing
– isActive() returns true or false
– isWon() returns true or false
– isDrawn() returns true or false
• GameView:
– placeSymbol(Symbol, X, Y) returns Success, Failure
– showScores(PlayerOneScore, PlayerTwoScore)
returns nothing. 23
Thank You
Questions and comments?
24

More Related Content

Similar to Object-Oriented (OO) Design Principles for Mobile Apps

Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Ganapathi M
 
Assessing computational thinking
Assessing computational thinkingAssessing computational thinking
Assessing computational thinkingDaniel Duckworth
 
Three dimensional modeling
Three dimensional modelingThree dimensional modeling
Three dimensional modelingHCS
 
Game design 2 (2013): Lecture 14 - Revision
Game design 2 (2013): Lecture 14 - RevisionGame design 2 (2013): Lecture 14 - Revision
Game design 2 (2013): Lecture 14 - RevisionDavid Farrell
 
2021 videojuego matematico-guia docentes-v1.1
2021 videojuego matematico-guia docentes-v1.12021 videojuego matematico-guia docentes-v1.1
2021 videojuego matematico-guia docentes-v1.1gabitachica
 
Game Design 2: UI in Games - Revision Lecture
Game Design 2: UI in Games - Revision LectureGame Design 2: UI in Games - Revision Lecture
Game Design 2: UI in Games - Revision LectureDavid Farrell
 
Introducting the art pipeline
Introducting the art pipelineIntroducting the art pipeline
Introducting the art pipelineDavid Edwards
 
Ropossum: A Game That Generates Itself
Ropossum: A Game That Generates ItselfRopossum: A Game That Generates Itself
Ropossum: A Game That Generates ItselfMohammad Shaker
 
Geometry 3D Shapes
Geometry 3D ShapesGeometry 3D Shapes
Geometry 3D ShapesMahriAutumn
 
How the Heck do you Teach Level Design? Educating in the Studio
How the Heck do you Teach Level Design? Educating in the StudioHow the Heck do you Teach Level Design? Educating in the Studio
How the Heck do you Teach Level Design? Educating in the StudioChristopher Totten
 
Authentic Learning: Some ideas for Junior High
Authentic Learning: Some ideas for Junior HighAuthentic Learning: Some ideas for Junior High
Authentic Learning: Some ideas for Junior HighPaul Herring
 
10 ict gm_game_assignment_2013
10 ict gm_game_assignment_201310 ict gm_game_assignment_2013
10 ict gm_game_assignment_2013hccit
 
Game design 2 (2013): Lecture 12 - Usability, Layout and Metaphor
Game design 2 (2013): Lecture 12 - Usability, Layout and MetaphorGame design 2 (2013): Lecture 12 - Usability, Layout and Metaphor
Game design 2 (2013): Lecture 12 - Usability, Layout and MetaphorDavid Farrell
 

Similar to Object-Oriented (OO) Design Principles for Mobile Apps (20)

Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0
 
Assessing computational thinking
Assessing computational thinkingAssessing computational thinking
Assessing computational thinking
 
Unit 4
Unit 4Unit 4
Unit 4
 
Three dimensional modeling
Three dimensional modelingThree dimensional modeling
Three dimensional modeling
 
Game design 2 (2013): Lecture 14 - Revision
Game design 2 (2013): Lecture 14 - RevisionGame design 2 (2013): Lecture 14 - Revision
Game design 2 (2013): Lecture 14 - Revision
 
2021 videojuego matematico-guia docentes-v1.1
2021 videojuego matematico-guia docentes-v1.12021 videojuego matematico-guia docentes-v1.1
2021 videojuego matematico-guia docentes-v1.1
 
Game Design 2: UI in Games - Revision Lecture
Game Design 2: UI in Games - Revision LectureGame Design 2: UI in Games - Revision Lecture
Game Design 2: UI in Games - Revision Lecture
 
Introducting the art pipeline
Introducting the art pipelineIntroducting the art pipeline
Introducting the art pipeline
 
Game Night Session 1
Game Night Session 1Game Night Session 1
Game Night Session 1
 
Ropossum: A Game That Generates Itself
Ropossum: A Game That Generates ItselfRopossum: A Game That Generates Itself
Ropossum: A Game That Generates Itself
 
Geometry 3D Shapes
Geometry 3D ShapesGeometry 3D Shapes
Geometry 3D Shapes
 
Oo aand d-overview
Oo aand d-overviewOo aand d-overview
Oo aand d-overview
 
How the Heck do you Teach Level Design? Educating in the Studio
How the Heck do you Teach Level Design? Educating in the StudioHow the Heck do you Teach Level Design? Educating in the Studio
How the Heck do you Teach Level Design? Educating in the Studio
 
Authentic Learning: Some ideas for Junior High
Authentic Learning: Some ideas for Junior HighAuthentic Learning: Some ideas for Junior High
Authentic Learning: Some ideas for Junior High
 
Reza talk
Reza talkReza talk
Reza talk
 
Proj1
Proj1Proj1
Proj1
 
Proj1
Proj1Proj1
Proj1
 
10 ict gm_game_assignment_2013
10 ict gm_game_assignment_201310 ict gm_game_assignment_2013
10 ict gm_game_assignment_2013
 
Game design 2 (2013): Lecture 12 - Usability, Layout and Metaphor
Game design 2 (2013): Lecture 12 - Usability, Layout and MetaphorGame design 2 (2013): Lecture 12 - Usability, Layout and Metaphor
Game design 2 (2013): Lecture 12 - Usability, Layout and Metaphor
 
Oops in java
Oops in javaOops in java
Oops in java
 

More from ShivamChaturvedi67 (16)

ddc cinverter control design process.ppt
ddc cinverter control design process.pptddc cinverter control design process.ppt
ddc cinverter control design process.ppt
 
ffCCMPFCInductorDesignwithPowderCore.ppt
ffCCMPFCInductorDesignwithPowderCore.pptffCCMPFCInductorDesignwithPowderCore.ppt
ffCCMPFCInductorDesignwithPowderCore.ppt
 
transformer-and-dc-motor control designs
transformer-and-dc-motor control designstransformer-and-dc-motor control designs
transformer-and-dc-motor control designs
 
magnetism_qr.pptx
magnetism_qr.pptxmagnetism_qr.pptx
magnetism_qr.pptx
 
Update7622.pptx
Update7622.pptxUpdate7622.pptx
Update7622.pptx
 
_8_EE462L_Fall2011_DC_DC_BuckBoost_PPT.ppt
_8_EE462L_Fall2011_DC_DC_BuckBoost_PPT.ppt_8_EE462L_Fall2011_DC_DC_BuckBoost_PPT.ppt
_8_EE462L_Fall2011_DC_DC_BuckBoost_PPT.ppt
 
Education_selecting key discovery tools for education research_v1_2021.pptx
Education_selecting key discovery tools for education research_v1_2021.pptxEducation_selecting key discovery tools for education research_v1_2021.pptx
Education_selecting key discovery tools for education research_v1_2021.pptx
 
Ch05.pdf
Ch05.pdfCh05.pdf
Ch05.pdf
 
Ch05-converted.pptx
Ch05-converted.pptxCh05-converted.pptx
Ch05-converted.pptx
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
android.ppt
android.pptandroid.ppt
android.ppt
 
1_5_Python_to_Java.pptx
1_5_Python_to_Java.pptx1_5_Python_to_Java.pptx
1_5_Python_to_Java.pptx
 
l7-pointers.ppt
l7-pointers.pptl7-pointers.ppt
l7-pointers.ppt
 
Lecture-3.ppt
Lecture-3.pptLecture-3.ppt
Lecture-3.ppt
 
Lecture-2.ppt
Lecture-2.pptLecture-2.ppt
Lecture-2.ppt
 
Lecture-1.ppt
Lecture-1.pptLecture-1.ppt
Lecture-1.ppt
 

Recently uploaded

Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 

Recently uploaded (20)

Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 

Object-Oriented (OO) Design Principles for Mobile Apps

  • 1. Object-Oriented (OO) Design CSE 5236: Mobile Application Development Course Coordinator: Dr. Rajiv Ramnath Instructor: Adam C. Champion, Ph.D. Reading: Applying UML and Patterns, Chaps. 1, 6 (OO ref.); Big Nerd Ranch Guide, Chap. 2 (Android/MVC) 1
  • 2. Elements of Good OO Design • Idea: Capture complexity of real-world problems, solutions via objects – Classes and responsibilities – Polymorphism helps represent the real-world – Achieve system goals through collaboration • Principles: Loose coupling, high cohesion – Abstraction – Encapsulation, information hiding • Methodology: Scenario-Driven Design – Implement objects needed for vertical slices of system • Technique: CRC-Card-Based Design 2
  • 3. Terminology Check • Class • Object • Method • Function • Class method • Subclass (implementation) • Subtype (interface) • Interface • Abstract class • Virtual method You should know what each term means! 3
  • 4. OO Design Process • Capture narratives of the environment, application (app) – Via observations, talking with domain experts, stakeholders, end users – Identify specific “circumstances” where an app would be used – Capture using text, storyboards, sketches • Identify domain classes, assign responsibilities; collaborators • Evaluate using OO Checklist • Develop the application flow: use cases, screen flows • Map domain model to Android framework model • Map app flow to framework model; connect UI to domain model; identify collaborators, update model/flow • Add contracts • Evaluate using OO Checklist (again) 4
  • 5. Identify Objects and Classes • Examine nouns, noun phrases as candidates • Adjectives: candidate attributes or subtypes • Group into categories: potential abstract classes, superclasses • Write down the purpose of each class • Eliminate redundant or non-domain classes 5
  • 6. Identify, Assign Responsibilities • Start with verbs and verb phrases (i.e. actions) • Assign to the appropriate classes – Distribute evenly: don’t give one class too much work – Don’t break the class definition – Locate responsibility with information – Locate related information together 6
  • 7. Map Domain Model to Framework Patterns • Usually a variation of MVC 7
  • 8. Identify Collaborations • Examine narratives, storyboards, use cases • Create scenarios • Walkthrough scenarios • Identify interactions between classes – These are the collaborations 8
  • 9. Evaluate Using Design Checklist • Each class must have: – Clear name – Cohesive description of responsibility – Long-lived state – Collaborators 9
  • 10. Record on CRC Cards (1) Source: K. Beck and W. Cunningham, “A Laboratory For Teaching Object-Oriented Thinking,” Proc. ACM OOPSLA, 1989. http://c2.com/doc/oopsla89/paper.html 10
  • 11. Record on CRC Cards (2) Sources: K. Beck and W. Cunningham, “A Laboratory For Teaching Object- Oriented Thinking,” Proc. ACM OOPSLA, 1989; C. Larman, Applying UML and Patterns, 3rd ed., Addison-Wesley, 2004. 11
  • 12. Exercise: Tic-Tac-Toe • Tic-tac-toe, also spelled tick-tack-toe, or noughts and crosses, as it is known in the UK, Ireland, Australia, New Zealand, is a pencil-and- paper game for two players, who take turns marking the spaces in a 3×3 grid with the symbols X and O respectively. The X player usually goes first. The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game. • Extend this by adding a narrative about playing the game on an Android device: Tic-tac-toe for Android will implement the Tic-tac-toe paper game as an Android app. In it, human users will be able to play Tic-tac-toe against the computer. Multiple games may be played in each session, with either the computer playing first or the human playing first on an electronic board that will be displayed on the device’s touch screen. Scores for each session will be accumulated. If the user quits the session, scores will be reset. 12
  • 13. Nouns and Verbs • Nouns: pencil, paper, game, nought, cross, player, X, O, space, symbol, grid, mark, vertical row, horizontal row, diagonal row, human user, human, computer, session, board, touchscreen, score. (Candidate objects and classes) • Verbs: take turn, mark, goes, place, win, implement, play, playing first, display, accumulate, quit, reset. (Candidate responsibilities) 13
  • 14. Consolidate: Nouns • Remove pencil, paper, touchscreen – physical objects • Symbol and mark identical – retain symbol. • User vs. player – retain player • Remove one of board and grid • Remove touchscreen – physical • Row is a component • Session is an instance of game 14
  • 15. Consolidate: Verbs • Take turn, goes, play – retain play • Mark vs. place vs. …? Use place symbol • Remove implement – irrelevant to game • Retain display, accumulate, exit and reset 15
  • 16. Candidate Classes, Responsibilities • Classes: Symbol, Player, Human, Computer, Board, Row, and Game (with attribute Score) • Instances: O, X of the class Symbol • Responsibilities: play, place, display, accumulate (scores), quit, and reset. 16
  • 17. Allocate Responsibilities to Classes • Class Game is allocated the responsibilities: play, accumulateScores, quit, and reset. • Class Board has Display responsibilities. • Class GameGrid has Place. • Symbol, Player, Human, Computer, and Row have no responsibilities yet. Keep? 17
  • 18. Map Domain Model to Framework Patterns • Controller classes map to Activities, e.g. GameSession • Visual elements (if any, remember we’re doing domain object design) map to views • Pure domain objects map to “plain old Java object” (POJO) hierarchies 18
  • 19. General Scenario • Start a new game. • Determine who plays first: the human or the computer. Assign the X symbol to the first player; assign the O symbol to the second player. • The first player places his symbol at an empty location on the board. The second player does likewise. Repeat until one player has three of his symbols in a row, column, or diagonal, or no more squares are in play, in which case the game ends in a draw. • Accumulate scores for the players. The winning player’s score increments by 1; the losing player’s score does not change. In a draw, both players’ scores remain the same. • If the user wishes, start a new game; else, quit. 19
  • 20. Screens and Screen Flows in Tic-Tac-Toe 20
  • 21. Scenario Walkthrough – Verification, Identifying Collaborators • No class to respond to starting new game. Create one: – GameController? – GameController and Game collaborate • Symbol creation, placement? Symbol and Board. • placeSymbol invokes Play? • Game needs checkResult? • Board, GameGrid and Game are collaborators. • Etc. 21
  • 22. Final Classes, Responsibilities • Game: Represents a single Tic-Tac-Toe game. – Responsibilities: play, checkResult – Collaborators: GameSession, GameView, Grid. • GameView: Represents the visual display of a Tic-Tac-Toe game. – Responsibilities: placeSymbol, showScores – Collaborators: Game • GameGrid: Represents 3×3 Tic-Tac-Toe grid. – Responsibilities: placeSymbol, getEmptySquares – Collaborators: Game • GameSession: Represents Tic-Tac-Toe play session (multiple games) – Responsibilities: playNewGame, quit, decidePlayers, accumulateScores – Collaborators: Game, GameView • Symbol – represents a Tic-Tac-Toe symbol (i.e., an X or an O) – Responsibilities: None – Collaborators: Game 22
  • 23. Contracts • Game: – play(Grid, Symbol, x, y) returns Success, Failure – checkResultAndSetState(Grid) returns nothing – isActive() returns true or false – isWon() returns true or false – isDrawn() returns true or false • GameView: – placeSymbol(Symbol, X, Y) returns Success, Failure – showScores(PlayerOneScore, PlayerTwoScore) returns nothing. 23
  • 24. Thank You Questions and comments? 24