SlideShare a Scribd company logo
Lecture-7
Instructor Name:
Object Oriented Programming
Today’s Lecture
 Object Interaction
 Modularization & Abstraction
2
Object Interaction & Collaboration
Message Passing
 An Application is set of Cooperating Objects that communicate with
each other
 Objects communicate by sending messages
 When an object sends a message to another object, an operation is
invoked in the receiving object
 The aim of modelling object interaction is to determine the most
appropriate scheme of message passing between objects to support a
particular user requirement
 In Java , “Message Passing” is done by calling methods.
3
Object Interaction & Collaboration
A Digital Clock Example
 An Application is set of CooperatingObjects that communicate with
each other
 Objects communicate by sending messages
 When an object sends a message to another object, an operation is
invoked in the receiving object
 The aim of modelling object interaction is to determine the most
appropriate scheme of message passing between objects to support a
particular user requirement
 In Java , “Message Passing” is done by calling methods.
4
Object Interaction & Collaboration
A Digital Clock Example
 Can you guess the implementation of clock?
5
Object Interaction & Collaboration
A Digital Clock Example
 First Idea: to implement a whole clock display in single class.
 If the problem is bigger than a digital clock then??
 Another approach (Abstraction and Modularization):
 Divide the problem in sub-components and then again sub-sub-
components and so on, until then individual problem are small
enough to be easy to deal with (Modularization).
 Once sub-problem solved, don’t think about in detail any more
(Abstraction)
6
Object Interaction & Collaboration
Abstraction & Modularization Example
 Suppose you want to go to Spain on holiday
 You can divide the problem into modules:
 Getting to the airport
 Flying from Britain to Spain
 Getting from Spanish airport to your hotel
 Each module can be solved independently, which simplifies things
 Use a taxi company to get to the airport, a travel agent to get to
Spain and a shuttle bus to get to your hotel
7
Object Interaction & Collaboration
Abstraction & Modularization Example
 You can have a hierarchy of modules
 Getting to the airport has modules:
Find the phone number of a taxi company
Book a taxi
Set your alarm
 Setting your alarm has modules…
 Key points:
 Dividing a problem into smaller problems simplifies things
 If modules are independent they are easier to solve
8
Object Interaction & Collaboration
Abstraction & Modularization Example
 Do not start by planning how to set your Alarm
 Do not start by planning how to get to the Airport
 Instead, abstract over these details
 Assume you will figure out later how to set your alarm and get to
the airport
 Start with the highest-level decision:
 Where in Spain do you want to go?
 Madrid,Malaga, Granada…?
9
Object Interaction & Collaboration
Abstraction & Modularization Example
 Now look at the next-highest decision:
 How should I get to Malaga? Fly from Bristol, Gatwick, Heathrow…?
 At this point think about flights and airports, but abstract over how to get
to the airport
 Now you can plan how to get to the airport
 But still abstract over how to set your alarm
 Eventually you can deal with how to set your alarm
 Key point:
 Working top-down as in this example is usually a good strategy
10
Object Interaction & Collaboration
Abstraction & Modularization Example
 Engineers in car company designing a car.
 Many Thinking areas
 Shape of body
 Size and location of engine
 Number and size of seats in the passenger area.
 Exact spacing of wheel
 An other engineer, whose job is to design engine
 Many thinking areas
 Clyinder
 Injection Mechansim
 Carburetor
 Elelctronics
 Spark plug (one Engineer will desgin it) 11
Object Interaction & Collaboration
Further Narrow Down the Problem Basic Class Structure
 Engineer may think of the spark plug as a complex artifact
of many parts. He might have done complex studies. To
determine exactly what kind of metal to use for the
contacts or what kind of material and production process
to use for the insulation.
12
Abstraction
Understanding Abstraction
 A designer at the highest level will regard a wheel as a single part.
Another engineer much further down the chain may spend her days
thinking about the chemical composition necessary to produce the right
materials to make the tires. For the tire engineer, the tire is a complex
thing. The car company will just buy the tire from the tire company and
then view it as a single entity. This is abstraction.
• =================================================
 The engineer in the car company abstracts from the details of the tire
manufacture to be able to concentrate on the details of the construction of,
say, the wheel. The designer designing the body shape of the car
abstracts from the technical details of the wheels and the engine to
concentrate on the design of the body (he will just be interested in the
size of the engine and the wheels).
13
Abstraction
Abstraction in Software
 In object-oriented programming, these components and subcomponents
are objects. If we were trying to construct a car in software, using an
object-oriented language, we would try to do what the car engineers do.
 Instead of implementing the car as a single, monolithic object,
 we would first construct separate objects for an engine, gearbox, wheel,
seat, and so on, and then assemble the car object from those smaller
objects.
 Now, back to our digital clock.
14
Abstraction
Abstraction in Software
 In object-oriented programming, these components and subcomponents
are objects. If we were trying to construct a car in software, using an
object-oriented language, we would try to do what the car engineers do.
 Instead of implementing the car as a single, monolithic object,
 we would first construct separate objects for an engine, gearbox, wheel,
seat, and so on, and then assemble the car object from those smaller
objects.
 Now, back to our digital clock.
15
Abstraction & Modularization
Abstraction
 Abstraction is the ability to ignore details of parts to focus attention
on a higher level of a problem.
Modularization
 Modularization is the process of dividing a whole into well-defined
parts, which can be built and examined separately, and which interact
in well-defined ways
16
Modularization
Modularization in the Digital Clock Example
 One way to look at it is to consider it as consisting of a single display with
four digits (two digits for the hours, two for the minutes).
 we can see that it could also be viewed as two separate two-digit displays
(one pair for the hours and one pair for the minutes).
 One pair starts at 0, increases by 1 each hour, and rolls back to 0 after
reaching its limit of 23. The other rolls back to 0 after reaching its limit of 59.
 The similarity in behavior of these two displays might then lead us to
abstract away even further from viewing the hours display and minutes
display distinctly. Instead, we might think of them as being objects that can
display values from zero up to a given limit. The value can be incremented,
but, if the value reaches the limit, it rolls over to zero.
 Now we seem to have reached an appropriate level of abstraction that we can
represent as a class: a two-digit display class.
17
Modularization
Modularization in the Digital Clock Example
18
Modularization
Implementing Digital Clock
19
Abstraction - NumberDisplay
Implementing Digital Clock
public class NumberDisplay
{
private int limit;
private int value;
Constructor and methods omitted.
}
20
Abstraction - NumberDisplay
Using an Abstract NumberDisplay
21
Abstraction - ClockDisplay
Implementing Digital Clock
public class ClockDisplay
{
private NumberDisplay hours;
private NumberDisplay minutes;
Constructor and methods omitted.
}
NumberDisplay class is use in ClockDisplay class. Here we have has-
a relationship
22
Abstraction - NumberDisplay
NumberDisplay Source Code
public class NumberDisplay
{
private int limit;
private int value;
public NumberDisplay(int rollOverLimit)
{
limit = rollOverLimit;
value = 0;
}
public void increment() {
value = (value + 1) % limit;
}
What modulu (%) operotor do here? 23
Abstraction - NumberDisplay
NumberDisplay Source Code
public int getValue()
{
return value;
}
public void setValue(int replacementValue)
{
if((replacementValue >= 0) &&(replacementValue < limit))
{
value = replacementValue;
}
}
24
Abstraction - NumberDisplay
NumberDisplay Source Code
public String getDisplayValue()
{
if(value < 10)
{
return "0" + value;
}
else
{
return "" + value;
}
}
}
25
Objects Creating Objects
ClockDisplay Source Code
public class ClockDisplay
{
private NumberDisplay hours;
private NumberDisplay minutes;
private String displayString;
public ClockDisplay() {
hours = new NumberDisplay(24);
minutes = new NumberDisplay(60);
…
}
}
26
Objects Creating Objects
ClockDisplay Source Code
public class ClockDisplay
{
private NumberDisplay hours;
private NumberDisplay minutes;
private String displayString;
public ClockDisplay() {
hours = new NumberDisplay(24);
minutes = new NumberDisplay(60);
}
public void timeTick() {
minutes.increment();
if(minutes.getValue() == 0)
{
hours.increment();
}
updateDisplay();
}
……… 27
Objects Creating Objects
ClockDisplay Source Code
public void setTime(inthour,intminute)
{
hours.setValue(hour);
minutes.setValue(minute);
updateDisplay();
}
public String getTime()
{
return displayString;
}
private void updateDisplay()
{
displayString = hours.getDisplayValue() + ":"+
minutes.getDisplayValue();
}
} 28
Objects Creating Objects
29
Internal & External Call
30
Internal & External Call
31
32

More Related Content

Similar to Lecture 7

Intro to C++ - Class 2 - Objects & Classes
Intro to C++ - Class 2 - Objects & ClassesIntro to C++ - Class 2 - Objects & Classes
Intro to C++ - Class 2 - Objects & Classes
Blue Elephant Consulting
 
Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++
Blue Elephant Consulting
 
L9
L9L9
L9
lksoo
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
TigistTilahun1
 
Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1
LK394
 
MongoDB World 2018: Building Intelligent Apps with MongoDB & Google Cloud
MongoDB World 2018: Building Intelligent Apps with MongoDB & Google CloudMongoDB World 2018: Building Intelligent Apps with MongoDB & Google Cloud
MongoDB World 2018: Building Intelligent Apps with MongoDB & Google Cloud
MongoDB
 
Design patterns
Design patternsDesign patterns
Design patterns
Mobicules Technologies
 
COMP111-Week-1_138439.pptx
COMP111-Week-1_138439.pptxCOMP111-Week-1_138439.pptx
COMP111-Week-1_138439.pptx
FarooqTariq8
 
Ad507
Ad507Ad507
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
NicheTech Com. Solutions Pvt. Ltd.
 
Think components. March 2017
Think components. March 2017Think components. March 2017
Think components. March 2017
Ivan Babak
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Bill Buchan
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular App
Katy Slemon
 
What is point cloud annotation?
What is point cloud annotation?What is point cloud annotation?
What is point cloud annotation?
Annotation Support
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
AbdullahMunir32
 
5 Design Patterns Explained
5 Design Patterns Explained5 Design Patterns Explained
5 Design Patterns Explained
Prabhjit Singh
 
Classes1
Classes1Classes1
Classes1
phanleson
 
Operator-less DataCenters -- A Reality
Operator-less DataCenters -- A RealityOperator-less DataCenters -- A Reality
Operator-less DataCenters -- A Reality
Kishore Arya
 
Operator-Less DataCenters A Near Future Reality
Operator-Less DataCenters A Near Future RealityOperator-Less DataCenters A Near Future Reality
Operator-Less DataCenters A Near Future Reality
Kishore Arya
 
How I ended up contributing to Magento core
How I ended up contributing to Magento coreHow I ended up contributing to Magento core
How I ended up contributing to Magento core
Alessandro Ronchi
 

Similar to Lecture 7 (20)

Intro to C++ - Class 2 - Objects & Classes
Intro to C++ - Class 2 - Objects & ClassesIntro to C++ - Class 2 - Objects & Classes
Intro to C++ - Class 2 - Objects & Classes
 
Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++
 
L9
L9L9
L9
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
 
Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1
 
MongoDB World 2018: Building Intelligent Apps with MongoDB & Google Cloud
MongoDB World 2018: Building Intelligent Apps with MongoDB & Google CloudMongoDB World 2018: Building Intelligent Apps with MongoDB & Google Cloud
MongoDB World 2018: Building Intelligent Apps with MongoDB & Google Cloud
 
Design patterns
Design patternsDesign patterns
Design patterns
 
COMP111-Week-1_138439.pptx
COMP111-Week-1_138439.pptxCOMP111-Week-1_138439.pptx
COMP111-Week-1_138439.pptx
 
Ad507
Ad507Ad507
Ad507
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
 
Think components. March 2017
Think components. March 2017Think components. March 2017
Think components. March 2017
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular App
 
What is point cloud annotation?
What is point cloud annotation?What is point cloud annotation?
What is point cloud annotation?
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
5 Design Patterns Explained
5 Design Patterns Explained5 Design Patterns Explained
5 Design Patterns Explained
 
Classes1
Classes1Classes1
Classes1
 
Operator-less DataCenters -- A Reality
Operator-less DataCenters -- A RealityOperator-less DataCenters -- A Reality
Operator-less DataCenters -- A Reality
 
Operator-Less DataCenters A Near Future Reality
Operator-Less DataCenters A Near Future RealityOperator-Less DataCenters A Near Future Reality
Operator-Less DataCenters A Near Future Reality
 
How I ended up contributing to Magento core
How I ended up contributing to Magento coreHow I ended up contributing to Magento core
How I ended up contributing to Magento core
 

More from talha ijaz

Lecture 23-24.pptx
Lecture 23-24.pptxLecture 23-24.pptx
Lecture 23-24.pptx
talha ijaz
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
talha ijaz
 
Lecture 20-21
Lecture 20-21Lecture 20-21
Lecture 20-21
talha ijaz
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
talha ijaz
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
talha ijaz
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
talha ijaz
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
talha ijaz
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
talha ijaz
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
talha ijaz
 
Visual perception
Visual perceptionVisual perception
Visual perception
talha ijaz
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
talha ijaz
 
Introduction
IntroductionIntroduction
Introduction
talha ijaz
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
talha ijaz
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
talha ijaz
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
talha ijaz
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
talha ijaz
 

More from talha ijaz (16)

Lecture 23-24.pptx
Lecture 23-24.pptxLecture 23-24.pptx
Lecture 23-24.pptx
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Lecture 20-21
Lecture 20-21Lecture 20-21
Lecture 20-21
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Visual perception
Visual perceptionVisual perception
Visual perception
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
 
Introduction
IntroductionIntroduction
Introduction
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 

Recently uploaded

Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
Bill641377
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
Sachin Paul
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
Sm321
 
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
apvysm8
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
roli9797
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
Timothy Spann
 
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
SaffaIbrahim1
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
Lars Albertsson
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
manishkhaire30
 
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
xclpvhuk
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
AndrzejJarynowski
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
sameer shah
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Fernanda Palhano
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
jitskeb
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
ihavuls
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
AlessioFois2
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
nyfuhyz
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
Timothy Spann
 

Recently uploaded (20)

Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
 
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
 
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
 
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
 

Lecture 7

  • 2. Today’s Lecture  Object Interaction  Modularization & Abstraction 2
  • 3. Object Interaction & Collaboration Message Passing  An Application is set of Cooperating Objects that communicate with each other  Objects communicate by sending messages  When an object sends a message to another object, an operation is invoked in the receiving object  The aim of modelling object interaction is to determine the most appropriate scheme of message passing between objects to support a particular user requirement  In Java , “Message Passing” is done by calling methods. 3
  • 4. Object Interaction & Collaboration A Digital Clock Example  An Application is set of CooperatingObjects that communicate with each other  Objects communicate by sending messages  When an object sends a message to another object, an operation is invoked in the receiving object  The aim of modelling object interaction is to determine the most appropriate scheme of message passing between objects to support a particular user requirement  In Java , “Message Passing” is done by calling methods. 4
  • 5. Object Interaction & Collaboration A Digital Clock Example  Can you guess the implementation of clock? 5
  • 6. Object Interaction & Collaboration A Digital Clock Example  First Idea: to implement a whole clock display in single class.  If the problem is bigger than a digital clock then??  Another approach (Abstraction and Modularization):  Divide the problem in sub-components and then again sub-sub- components and so on, until then individual problem are small enough to be easy to deal with (Modularization).  Once sub-problem solved, don’t think about in detail any more (Abstraction) 6
  • 7. Object Interaction & Collaboration Abstraction & Modularization Example  Suppose you want to go to Spain on holiday  You can divide the problem into modules:  Getting to the airport  Flying from Britain to Spain  Getting from Spanish airport to your hotel  Each module can be solved independently, which simplifies things  Use a taxi company to get to the airport, a travel agent to get to Spain and a shuttle bus to get to your hotel 7
  • 8. Object Interaction & Collaboration Abstraction & Modularization Example  You can have a hierarchy of modules  Getting to the airport has modules: Find the phone number of a taxi company Book a taxi Set your alarm  Setting your alarm has modules…  Key points:  Dividing a problem into smaller problems simplifies things  If modules are independent they are easier to solve 8
  • 9. Object Interaction & Collaboration Abstraction & Modularization Example  Do not start by planning how to set your Alarm  Do not start by planning how to get to the Airport  Instead, abstract over these details  Assume you will figure out later how to set your alarm and get to the airport  Start with the highest-level decision:  Where in Spain do you want to go?  Madrid,Malaga, Granada…? 9
  • 10. Object Interaction & Collaboration Abstraction & Modularization Example  Now look at the next-highest decision:  How should I get to Malaga? Fly from Bristol, Gatwick, Heathrow…?  At this point think about flights and airports, but abstract over how to get to the airport  Now you can plan how to get to the airport  But still abstract over how to set your alarm  Eventually you can deal with how to set your alarm  Key point:  Working top-down as in this example is usually a good strategy 10
  • 11. Object Interaction & Collaboration Abstraction & Modularization Example  Engineers in car company designing a car.  Many Thinking areas  Shape of body  Size and location of engine  Number and size of seats in the passenger area.  Exact spacing of wheel  An other engineer, whose job is to design engine  Many thinking areas  Clyinder  Injection Mechansim  Carburetor  Elelctronics  Spark plug (one Engineer will desgin it) 11
  • 12. Object Interaction & Collaboration Further Narrow Down the Problem Basic Class Structure  Engineer may think of the spark plug as a complex artifact of many parts. He might have done complex studies. To determine exactly what kind of metal to use for the contacts or what kind of material and production process to use for the insulation. 12
  • 13. Abstraction Understanding Abstraction  A designer at the highest level will regard a wheel as a single part. Another engineer much further down the chain may spend her days thinking about the chemical composition necessary to produce the right materials to make the tires. For the tire engineer, the tire is a complex thing. The car company will just buy the tire from the tire company and then view it as a single entity. This is abstraction. • =================================================  The engineer in the car company abstracts from the details of the tire manufacture to be able to concentrate on the details of the construction of, say, the wheel. The designer designing the body shape of the car abstracts from the technical details of the wheels and the engine to concentrate on the design of the body (he will just be interested in the size of the engine and the wheels). 13
  • 14. Abstraction Abstraction in Software  In object-oriented programming, these components and subcomponents are objects. If we were trying to construct a car in software, using an object-oriented language, we would try to do what the car engineers do.  Instead of implementing the car as a single, monolithic object,  we would first construct separate objects for an engine, gearbox, wheel, seat, and so on, and then assemble the car object from those smaller objects.  Now, back to our digital clock. 14
  • 15. Abstraction Abstraction in Software  In object-oriented programming, these components and subcomponents are objects. If we were trying to construct a car in software, using an object-oriented language, we would try to do what the car engineers do.  Instead of implementing the car as a single, monolithic object,  we would first construct separate objects for an engine, gearbox, wheel, seat, and so on, and then assemble the car object from those smaller objects.  Now, back to our digital clock. 15
  • 16. Abstraction & Modularization Abstraction  Abstraction is the ability to ignore details of parts to focus attention on a higher level of a problem. Modularization  Modularization is the process of dividing a whole into well-defined parts, which can be built and examined separately, and which interact in well-defined ways 16
  • 17. Modularization Modularization in the Digital Clock Example  One way to look at it is to consider it as consisting of a single display with four digits (two digits for the hours, two for the minutes).  we can see that it could also be viewed as two separate two-digit displays (one pair for the hours and one pair for the minutes).  One pair starts at 0, increases by 1 each hour, and rolls back to 0 after reaching its limit of 23. The other rolls back to 0 after reaching its limit of 59.  The similarity in behavior of these two displays might then lead us to abstract away even further from viewing the hours display and minutes display distinctly. Instead, we might think of them as being objects that can display values from zero up to a given limit. The value can be incremented, but, if the value reaches the limit, it rolls over to zero.  Now we seem to have reached an appropriate level of abstraction that we can represent as a class: a two-digit display class. 17
  • 18. Modularization Modularization in the Digital Clock Example 18
  • 20. Abstraction - NumberDisplay Implementing Digital Clock public class NumberDisplay { private int limit; private int value; Constructor and methods omitted. } 20
  • 21. Abstraction - NumberDisplay Using an Abstract NumberDisplay 21
  • 22. Abstraction - ClockDisplay Implementing Digital Clock public class ClockDisplay { private NumberDisplay hours; private NumberDisplay minutes; Constructor and methods omitted. } NumberDisplay class is use in ClockDisplay class. Here we have has- a relationship 22
  • 23. Abstraction - NumberDisplay NumberDisplay Source Code public class NumberDisplay { private int limit; private int value; public NumberDisplay(int rollOverLimit) { limit = rollOverLimit; value = 0; } public void increment() { value = (value + 1) % limit; } What modulu (%) operotor do here? 23
  • 24. Abstraction - NumberDisplay NumberDisplay Source Code public int getValue() { return value; } public void setValue(int replacementValue) { if((replacementValue >= 0) &&(replacementValue < limit)) { value = replacementValue; } } 24
  • 25. Abstraction - NumberDisplay NumberDisplay Source Code public String getDisplayValue() { if(value < 10) { return "0" + value; } else { return "" + value; } } } 25
  • 26. Objects Creating Objects ClockDisplay Source Code public class ClockDisplay { private NumberDisplay hours; private NumberDisplay minutes; private String displayString; public ClockDisplay() { hours = new NumberDisplay(24); minutes = new NumberDisplay(60); … } } 26
  • 27. Objects Creating Objects ClockDisplay Source Code public class ClockDisplay { private NumberDisplay hours; private NumberDisplay minutes; private String displayString; public ClockDisplay() { hours = new NumberDisplay(24); minutes = new NumberDisplay(60); } public void timeTick() { minutes.increment(); if(minutes.getValue() == 0) { hours.increment(); } updateDisplay(); } ……… 27
  • 28. Objects Creating Objects ClockDisplay Source Code public void setTime(inthour,intminute) { hours.setValue(hour); minutes.setValue(minute); updateDisplay(); } public String getTime() { return displayString; } private void updateDisplay() { displayString = hours.getDisplayValue() + ":"+ minutes.getDisplayValue(); } } 28
  • 32. 32