SlideShare a Scribd company logo
1 of 31
CH1. Object-Oriented Paradigm
© Taka Wang, 2017 1
Naive Problem
If I were to give you the task of wri2ng code to access a descrip2on
of shapes that were stored in a database and then display them.
© Taka Wang, 2017 2
Structural Programming thinking - possible steps
1. Locate the list of shapes in the database. (
)
2. Open up the list of shapes. ( )
3. Sort the list according to some rules. ( )
4. Display the individual shapes on the monitor. (
)
© Taka Wang, 2017 3
Func%onal Decomposi%on ( )
4a. Iden)fy the type of shape. ( )
4b. Get the loca-on of the shape. ( )
4c. Call the appropriate func2on that will display the shape, giving
it the shape’s loca2on. (
Func2on)
© Taka Wang, 2017 4
Func%onal Decomposi%on
1. (subprograms)
subprograms
(Why not delega7on?) << >>
2. Func7on
module
Func7on module << >>
© Taka Wang, 2017 5
1. ( )
2.
(OO )
3.
© Taka Wang, 2017 6
Dealing with Changes: Func2onal Decomposi2on
4c. Call the appropriate func2on that will display the shape, giving
it the shape’s loca2on. (
Func2on)
© Taka Wang, 2017 7
Dealing with Changes: Func2onal Decomposi2on
4c. Call the appropriate func2on that will display the shape, giving it the
shape’s loca2on. ( Func2on)
Using Modularity to Contain Varia2on
function: display shape
input: type of shape, description of shape
action:
switch (type of shape)
case square: put display function for square here
case circle: put display function for circle here
© Taka Wang, 2017 8
1. ( )
( )
2. type of shape, descrip5on of shape
( array of points )
© Taka Wang, 2017 9
Func%onal Decomposi%on
1. Weak cohesion (Cohesion refers to how “closely the opera6ons in a
rou6ne are related; cohesion as clarity because the more that
opera6ons are related in a rou6ne (or a class), the easier it is to
understand things.)
2. Tight Coupling (Coupling refers to “the strength of a connec6on
between two rou6nes. Coupling is a complement to cohesion.)
The goal is to create rou/nes with internal integrity (strong cohesion) and
small, direct, visible, and flexible rela/ons to other rou/nes (loose
coupling).
© Taka Wang, 2017 10
You are an instructor at a conference. People in your class have
another class to a5end following yours, but don’t know where it is
located. One of your responsibili>es is to make sure everyone
knows how to get to the next class.
© Taka Wang, 2017 11
1. Get list of people in the class.
2. For each person on this list, do the following:
1. Find the next class he or she is taking.
2. Find the loca;on of that class.
3. Find the way to get from your classroom to the person’s next
class.
4. Tell the person how to get to his or her next class.
© Taka Wang, 2017 12
1. A way of ge,ng the list of people in the class.
2. A way of ge,ng the schedule for each person in the class.
3. A program that gives someone direc<ons from your classrom to
any other classroom.
4. A control program that works for each person in the class and
does the reuqired steps for each person.
© Taka Wang, 2017 13
!
You would probably post direc2ons to go from this classroom to
the other classrooms and then tell everyone in the class, I have
posted the loca.ons of the classes following this in the back of the
room, as well as the loca.ons of the other classrooms. Please use
them to go to your next classroom.
© Taka Wang, 2017 14
1. Giving explicit direc+ons to everyone.
2. Giving general instruc+ons and then expect the each person will
figure out how to do the task individually. ( delega+on)
© Taka Wang, 2017 15
1.
2.
:
© Taka Wang, 2017 16
1.
2. ( )
3.
© Taka Wang, 2017 17
1. Conceptual: domain concepts
What am I responsibile for?
2. Specifica9on: interface
How am I used?
3. Implementa9on: How do I fulfill
my responsibili9es?"
© Taka Wang, 2017 18
(you are telling people what you want, not how to
do it.)
( )
© Taka Wang, 2017 19
Object-Oriented Paradigm
© Taka Wang, 2017 20
The objects were iden*fied by looking at the en**es in the
problem domain. I iden*fied the responsibili1es (or methods) for
each object by looking at what these en**es need to do.
© Taka Wang, 2017 21
Apply Fowler's Perspec/ves
• At the conceptual level, an object is a set of responsibili5es. (
)
• At the specifica-on level, an object is a set of methods
(behaviors) that can be invoked by other objects or by itself. (
)
• At the implementa-on level, an object is code and data and
computa5onal interac5ons between them.
© Taka Wang, 2017 22
Object-Oriented Approach
1. Start the control program.
2. Instan4ate the collec4on of students in the classroom.
3. Tell the collec4on to have the students go to their next class.
4. The collec4on tells each student to go to his or her next class.
5. Each student:
1. Finds where his next class is.
2. Determines how to get there.
3. Goes there.
6. Done.
© Taka Wang, 2017 23
Abstract and Polymorphism
• Student abstract class, GraduageStudent and RegularStudent classes.
• Abstract classes define what other, related, classes can do. Abstract
classes act as placeholders for other classes.
• Collec;on Student Concept (Abstract)
Student (Concrete)
•
Derived Class (Polymorphism)
© Taka Wang, 2017 24
1. Locate the list of shapes in the database. (
)
2. Open up the list of shapes. ( )
3. Sort the list according to some rules. ( )
4. Display the individual shapes on the monitor. (
)
© Taka Wang, 2017 25
Object-Oriented Approach (1/2)
© Taka Wang, 2017 26
Object-Oriented Approach (2/2)
1. ShapeDataBase
2. database object instan0ate
collec0on .
3. Collec0on
4. Collec0on
5. Collec0on
6.
© Taka Wang, 2017 27
• ( )
1. Concrete Class
2. Derived Class
•
1. Collec6on Sor6ng algorithm
The object-oriented approach has limited the impact of changing
requirements.
© Taka Wang, 2017 28
1.
2. (
depend on interface, not implementa4on)
3. The internals of an object are unknown to other objects. (
< >)
© Taka Wang, 2017 29
Take away
1.
2. (
)
3. OO
4. (placeholder and delega5on)
5. ( )
© Taka Wang, 2017 30
Thank you1
1
( )
© Taka Wang, 2017 31

More Related Content

What's hot

Theory and evaluation metrics for learning disentangled representations
Theory and evaluation metrics for learning disentangled representationsTheory and evaluation metrics for learning disentangled representations
Theory and evaluation metrics for learning disentangled representations
Kien Duc Do
 
Complex Relations Extraction
Complex Relations ExtractionComplex Relations Extraction
Complex Relations Extraction
Naveed Afzal
 
Final sdp ppt
Final sdp pptFinal sdp ppt
Final sdp ppt
nancy_17
 
G6 m2-a-lesson 8-t
G6 m2-a-lesson 8-tG6 m2-a-lesson 8-t
G6 m2-a-lesson 8-t
mlabuski
 

What's hot (8)

[OOP - Lec 08] Encapsulation (Information Hiding)
[OOP - Lec 08] Encapsulation (Information Hiding)[OOP - Lec 08] Encapsulation (Information Hiding)
[OOP - Lec 08] Encapsulation (Information Hiding)
 
Theory and evaluation metrics for learning disentangled representations
Theory and evaluation metrics for learning disentangled representationsTheory and evaluation metrics for learning disentangled representations
Theory and evaluation metrics for learning disentangled representations
 
Semi-Supervised Learning with Variational Bayesian Inference and Maximum Unce...
Semi-Supervised Learning with Variational Bayesian Inference and Maximum Unce...Semi-Supervised Learning with Variational Bayesian Inference and Maximum Unce...
Semi-Supervised Learning with Variational Bayesian Inference and Maximum Unce...
 
Complex Relations Extraction
Complex Relations ExtractionComplex Relations Extraction
Complex Relations Extraction
 
Final sdp ppt
Final sdp pptFinal sdp ppt
Final sdp ppt
 
Cohesion and coupling software desgin engineering
Cohesion and coupling  software desgin engineeringCohesion and coupling  software desgin engineering
Cohesion and coupling software desgin engineering
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
 
G6 m2-a-lesson 8-t
G6 m2-a-lesson 8-tG6 m2-a-lesson 8-t
G6 m2-a-lesson 8-t
 

Viewers also liked

Application Of Software Design Pattern
Application Of Software Design PatternApplication Of Software Design Pattern
Application Of Software Design Pattern
guest46da5428
 
SOFTWARE QUALITY ASSURANCE AND DESIGN PATTERNS
SOFTWARE QUALITY ASSURANCE AND DESIGN PATTERNSSOFTWARE QUALITY ASSURANCE AND DESIGN PATTERNS
SOFTWARE QUALITY ASSURANCE AND DESIGN PATTERNS
shubbhi
 
Time series analysis of collaborative activities-CRIWG2012
Time series analysis of collaborative activities-CRIWG2012Time series analysis of collaborative activities-CRIWG2012
Time series analysis of collaborative activities-CRIWG2012
Irene-Angelica Chounta
 
程式の工業革命 初稿
程式の工業革命 初稿程式の工業革命 初稿
程式の工業革命 初稿
HoShi YoRu
 

Viewers also liked (20)

Application Of Software Design Pattern
Application Of Software Design PatternApplication Of Software Design Pattern
Application Of Software Design Pattern
 
SOFTWARE QUALITY ASSURANCE AND DESIGN PATTERNS
SOFTWARE QUALITY ASSURANCE AND DESIGN PATTERNSSOFTWARE QUALITY ASSURANCE AND DESIGN PATTERNS
SOFTWARE QUALITY ASSURANCE AND DESIGN PATTERNS
 
A Semi-naive Bayes Classifier with Grouping of Cases
A Semi-naive Bayes Classifier with Grouping of CasesA Semi-naive Bayes Classifier with Grouping of Cases
A Semi-naive Bayes Classifier with Grouping of Cases
 
Lecture10 - Naïve Bayes
Lecture10 - Naïve BayesLecture10 - Naïve Bayes
Lecture10 - Naïve Bayes
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Overview of Software QA and What is Software Quality
Overview of Software QA and What is Software QualityOverview of Software QA and What is Software Quality
Overview of Software QA and What is Software Quality
 
Design pattern
Design patternDesign pattern
Design pattern
 
Android (software) Design Pattern
Android (software) Design PatternAndroid (software) Design Pattern
Android (software) Design Pattern
 
Time series analysis of collaborative activities-CRIWG2012
Time series analysis of collaborative activities-CRIWG2012Time series analysis of collaborative activities-CRIWG2012
Time series analysis of collaborative activities-CRIWG2012
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software Engineering
 
Naive Bayes with Conditionally Dependent Data
Naive Bayes with Conditionally Dependent DataNaive Bayes with Conditionally Dependent Data
Naive Bayes with Conditionally Dependent Data
 
Cost of software quality ( software quality assurance )
Cost of software quality ( software quality assurance )Cost of software quality ( software quality assurance )
Cost of software quality ( software quality assurance )
 
Code style 2014-07-18-pub
Code style 2014-07-18-pubCode style 2014-07-18-pub
Code style 2014-07-18-pub
 
Observer Software Design Pattern
Observer Software Design Pattern Observer Software Design Pattern
Observer Software Design Pattern
 
Creational Design Patterns
Creational Design PatternsCreational Design Patterns
Creational Design Patterns
 
Qlync RD 第三屆讀書會候選清單
Qlync RD 第三屆讀書會候選清單Qlync RD 第三屆讀書會候選清單
Qlync RD 第三屆讀書會候選清單
 
DMTM 2015 - 05 Association Rules
DMTM 2015 - 05 Association RulesDMTM 2015 - 05 Association Rules
DMTM 2015 - 05 Association Rules
 
被遺忘的資訊洩漏 / Information Leakage in Taiwan
被遺忘的資訊洩漏 / Information Leakage in Taiwan被遺忘的資訊洩漏 / Information Leakage in Taiwan
被遺忘的資訊洩漏 / Information Leakage in Taiwan
 
程式の工業革命 初稿
程式の工業革命 初稿程式の工業革命 初稿
程式の工業革命 初稿
 
Asp.net mvc 概觀介紹
Asp.net mvc 概觀介紹Asp.net mvc 概觀介紹
Asp.net mvc 概觀介紹
 

Similar to Design Pattern Explained CH1

Understanding Software Cohesion Metrics: Experimental Assessment of Conceptua...
Understanding Software Cohesion Metrics:Experimental Assessment of Conceptua...Understanding Software Cohesion Metrics:Experimental Assessment of Conceptua...
Understanding Software Cohesion Metrics: Experimental Assessment of Conceptua...
Bruno C. da Silva
 
The Valladolid Presentation - Nov, 16, 2011
The Valladolid Presentation - Nov, 16, 2011The Valladolid Presentation - Nov, 16, 2011
The Valladolid Presentation - Nov, 16, 2011
sdemetri
 
An Empirical Study on How Developers Reason about Module Cohesion
An Empirical Study on How Developers Reason about Module CohesionAn Empirical Study on How Developers Reason about Module Cohesion
An Empirical Study on How Developers Reason about Module Cohesion
Bruno C. da Silva
 

Similar to Design Pattern Explained CH1 (20)

Orchestration Graphs: Enabling Rich Learning Scenarios at Scale
Orchestration Graphs: Enabling Rich Learning Scenarios at ScaleOrchestration Graphs: Enabling Rich Learning Scenarios at Scale
Orchestration Graphs: Enabling Rich Learning Scenarios at Scale
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
TRiPODの紹介
TRiPODの紹介TRiPODの紹介
TRiPODの紹介
 
E3
E3E3
E3
 
A New Approach of Learning Hierarchy Construction Based on Fuzzy Logic
A New Approach of Learning Hierarchy Construction Based on Fuzzy LogicA New Approach of Learning Hierarchy Construction Based on Fuzzy Logic
A New Approach of Learning Hierarchy Construction Based on Fuzzy Logic
 
A Multi-level Methodology for Developing UML Sequence Diagrams
A Multi-level Methodology for Developing UML Sequence DiagramsA Multi-level Methodology for Developing UML Sequence Diagrams
A Multi-level Methodology for Developing UML Sequence Diagrams
 
Data Structures 2004
Data Structures 2004Data Structures 2004
Data Structures 2004
 
Ooad 2
Ooad 2Ooad 2
Ooad 2
 
Ooad
OoadOoad
Ooad
 
Assessment 2......
Assessment 2......Assessment 2......
Assessment 2......
 
Generating domain specific sentiment lexicons using the Web Directory
Generating domain specific sentiment lexicons using the Web Directory Generating domain specific sentiment lexicons using the Web Directory
Generating domain specific sentiment lexicons using the Web Directory
 
Placement management system
Placement management systemPlacement management system
Placement management system
 
Understanding Software Cohesion Metrics: Experimental Assessment of Conceptua...
Understanding Software Cohesion Metrics:Experimental Assessment of Conceptua...Understanding Software Cohesion Metrics:Experimental Assessment of Conceptua...
Understanding Software Cohesion Metrics: Experimental Assessment of Conceptua...
 
The Valladolid Presentation - Nov, 16, 2011
The Valladolid Presentation - Nov, 16, 2011The Valladolid Presentation - Nov, 16, 2011
The Valladolid Presentation - Nov, 16, 2011
 
An Empirical Study on How Developers Reason about Module Cohesion
An Empirical Study on How Developers Reason about Module CohesionAn Empirical Study on How Developers Reason about Module Cohesion
An Empirical Study on How Developers Reason about Module Cohesion
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design Patterns
 
SE18_Lec 08_UML Class Diagram
SE18_Lec 08_UML Class DiagramSE18_Lec 08_UML Class Diagram
SE18_Lec 08_UML Class Diagram
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur University
 

More from Jamie (Taka) Wang

More from Jamie (Taka) Wang (20)

20200606_insight_Ignition
20200606_insight_Ignition20200606_insight_Ignition
20200606_insight_Ignition
 
20200727_Insight workstation
20200727_Insight workstation20200727_Insight workstation
20200727_Insight workstation
 
20200723_insight_release_plan
20200723_insight_release_plan20200723_insight_release_plan
20200723_insight_release_plan
 
20210105_量產技轉
20210105_量產技轉20210105_量產技轉
20210105_量產技轉
 
20200808自營電商平台策略討論
20200808自營電商平台策略討論20200808自營電商平台策略討論
20200808自營電商平台策略討論
 
20200427_hardware
20200427_hardware20200427_hardware
20200427_hardware
 
20200429_ec
20200429_ec20200429_ec
20200429_ec
 
20200607_insight_sync
20200607_insight_sync20200607_insight_sync
20200607_insight_sync
 
20220113_product_day
20220113_product_day20220113_product_day
20220113_product_day
 
20200429_software
20200429_software20200429_software
20200429_software
 
20200602_insight_business
20200602_insight_business20200602_insight_business
20200602_insight_business
 
20200408_gen11_sequence_diagram
20200408_gen11_sequence_diagram20200408_gen11_sequence_diagram
20200408_gen11_sequence_diagram
 
20190827_activity_diagram
20190827_activity_diagram20190827_activity_diagram
20190827_activity_diagram
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
20161220 - microservice
20161220 - microservice20161220 - microservice
20161220 - microservice
 
20160217 - Overview of Vortex Intelligent Data Sharing Platform
20160217 - Overview of Vortex Intelligent Data Sharing Platform20160217 - Overview of Vortex Intelligent Data Sharing Platform
20160217 - Overview of Vortex Intelligent Data Sharing Platform
 
20151111 - IoT Sync Up
20151111 - IoT Sync Up20151111 - IoT Sync Up
20151111 - IoT Sync Up
 
20151207 - iot strategy
20151207 - iot strategy20151207 - iot strategy
20151207 - iot strategy
 
20141210 - Microservice Container
20141210 - Microservice Container20141210 - Microservice Container
20141210 - Microservice Container
 
20161027 - edge part2
20161027 - edge part220161027 - edge part2
20161027 - edge part2
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 

Design Pattern Explained CH1

  • 2. Naive Problem If I were to give you the task of wri2ng code to access a descrip2on of shapes that were stored in a database and then display them. © Taka Wang, 2017 2
  • 3. Structural Programming thinking - possible steps 1. Locate the list of shapes in the database. ( ) 2. Open up the list of shapes. ( ) 3. Sort the list according to some rules. ( ) 4. Display the individual shapes on the monitor. ( ) © Taka Wang, 2017 3
  • 4. Func%onal Decomposi%on ( ) 4a. Iden)fy the type of shape. ( ) 4b. Get the loca-on of the shape. ( ) 4c. Call the appropriate func2on that will display the shape, giving it the shape’s loca2on. ( Func2on) © Taka Wang, 2017 4
  • 5. Func%onal Decomposi%on 1. (subprograms) subprograms (Why not delega7on?) << >> 2. Func7on module Func7on module << >> © Taka Wang, 2017 5
  • 6. 1. ( ) 2. (OO ) 3. © Taka Wang, 2017 6
  • 7. Dealing with Changes: Func2onal Decomposi2on 4c. Call the appropriate func2on that will display the shape, giving it the shape’s loca2on. ( Func2on) © Taka Wang, 2017 7
  • 8. Dealing with Changes: Func2onal Decomposi2on 4c. Call the appropriate func2on that will display the shape, giving it the shape’s loca2on. ( Func2on) Using Modularity to Contain Varia2on function: display shape input: type of shape, description of shape action: switch (type of shape) case square: put display function for square here case circle: put display function for circle here © Taka Wang, 2017 8
  • 9. 1. ( ) ( ) 2. type of shape, descrip5on of shape ( array of points ) © Taka Wang, 2017 9
  • 10. Func%onal Decomposi%on 1. Weak cohesion (Cohesion refers to how “closely the opera6ons in a rou6ne are related; cohesion as clarity because the more that opera6ons are related in a rou6ne (or a class), the easier it is to understand things.) 2. Tight Coupling (Coupling refers to “the strength of a connec6on between two rou6nes. Coupling is a complement to cohesion.) The goal is to create rou/nes with internal integrity (strong cohesion) and small, direct, visible, and flexible rela/ons to other rou/nes (loose coupling). © Taka Wang, 2017 10
  • 11. You are an instructor at a conference. People in your class have another class to a5end following yours, but don’t know where it is located. One of your responsibili>es is to make sure everyone knows how to get to the next class. © Taka Wang, 2017 11
  • 12. 1. Get list of people in the class. 2. For each person on this list, do the following: 1. Find the next class he or she is taking. 2. Find the loca;on of that class. 3. Find the way to get from your classroom to the person’s next class. 4. Tell the person how to get to his or her next class. © Taka Wang, 2017 12
  • 13. 1. A way of ge,ng the list of people in the class. 2. A way of ge,ng the schedule for each person in the class. 3. A program that gives someone direc<ons from your classrom to any other classroom. 4. A control program that works for each person in the class and does the reuqired steps for each person. © Taka Wang, 2017 13
  • 14. ! You would probably post direc2ons to go from this classroom to the other classrooms and then tell everyone in the class, I have posted the loca.ons of the classes following this in the back of the room, as well as the loca.ons of the other classrooms. Please use them to go to your next classroom. © Taka Wang, 2017 14
  • 15. 1. Giving explicit direc+ons to everyone. 2. Giving general instruc+ons and then expect the each person will figure out how to do the task individually. ( delega+on) © Taka Wang, 2017 15
  • 17. 1. 2. ( ) 3. © Taka Wang, 2017 17
  • 18. 1. Conceptual: domain concepts What am I responsibile for? 2. Specifica9on: interface How am I used? 3. Implementa9on: How do I fulfill my responsibili9es?" © Taka Wang, 2017 18
  • 19. (you are telling people what you want, not how to do it.) ( ) © Taka Wang, 2017 19
  • 21. The objects were iden*fied by looking at the en**es in the problem domain. I iden*fied the responsibili1es (or methods) for each object by looking at what these en**es need to do. © Taka Wang, 2017 21
  • 22. Apply Fowler's Perspec/ves • At the conceptual level, an object is a set of responsibili5es. ( ) • At the specifica-on level, an object is a set of methods (behaviors) that can be invoked by other objects or by itself. ( ) • At the implementa-on level, an object is code and data and computa5onal interac5ons between them. © Taka Wang, 2017 22
  • 23. Object-Oriented Approach 1. Start the control program. 2. Instan4ate the collec4on of students in the classroom. 3. Tell the collec4on to have the students go to their next class. 4. The collec4on tells each student to go to his or her next class. 5. Each student: 1. Finds where his next class is. 2. Determines how to get there. 3. Goes there. 6. Done. © Taka Wang, 2017 23
  • 24. Abstract and Polymorphism • Student abstract class, GraduageStudent and RegularStudent classes. • Abstract classes define what other, related, classes can do. Abstract classes act as placeholders for other classes. • Collec;on Student Concept (Abstract) Student (Concrete) • Derived Class (Polymorphism) © Taka Wang, 2017 24
  • 25. 1. Locate the list of shapes in the database. ( ) 2. Open up the list of shapes. ( ) 3. Sort the list according to some rules. ( ) 4. Display the individual shapes on the monitor. ( ) © Taka Wang, 2017 25
  • 26. Object-Oriented Approach (1/2) © Taka Wang, 2017 26
  • 27. Object-Oriented Approach (2/2) 1. ShapeDataBase 2. database object instan0ate collec0on . 3. Collec0on 4. Collec0on 5. Collec0on 6. © Taka Wang, 2017 27
  • 28. • ( ) 1. Concrete Class 2. Derived Class • 1. Collec6on Sor6ng algorithm The object-oriented approach has limited the impact of changing requirements. © Taka Wang, 2017 28
  • 29. 1. 2. ( depend on interface, not implementa4on) 3. The internals of an object are unknown to other objects. ( < >) © Taka Wang, 2017 29
  • 30. Take away 1. 2. ( ) 3. OO 4. (placeholder and delega5on) 5. ( ) © Taka Wang, 2017 30
  • 31. Thank you1 1 ( ) © Taka Wang, 2017 31