SlideShare a Scribd company logo
CCH1D4
STRUKTUR DATA
Modularity and Data
Abstraction
describes a program organized into loosely
coupled, highly cohesive modules”
– Carrano and Prichard, p. 7
“a technique that keeps the complexity of a large
program manageable by systematically controlling
the interaction of its components”
– Carrano and Prichard, p. 106
2 1/23/2019
Modularity
CCH1D4-STRUKTUR DATA
Modularity is the degree to which a system's
components may be separated and recombined
Here we will know about
Abstract Data Type (ADT)
– to understand better about ADT, let’s see the illustration
3 1/23/2019
In Short :
CCH1D4-STRUKTUR DATA
Suppose we will make an information System to
store students record
There are 4 menus
– Add new data
– Delete data
– Edit data
– View stored data
4 1/23/2019
Student Information System
CCH1D4-STRUKTUR DATA
Basic Algorithm Writing Style
5 1/23/2019
What we usually do?
CCH1D4-STRUKTUR DATA
Type student < …
>
Dictionary
……
function add_student(…)
……
Algorithm
……
……
Function add_student( … )
……
Function delete_student( … )
……
Procedure …… ……
……
Type description of student, name, id,
class, etc.
Declaring Variables and name of functions
that will be used in main program
Main program, contains menu, interface,
etc.
The main program will use the functions
available or has been specified
Function specification, basic operation for
student
All in one file (one script)
3 parts of program or 3 modules
Type student < …
>
Dictionary
……
function add_student(…)
……
Algorithm
……
……
Function add_student( … )
……
Function delete_student( … )
……
Procedure …… ……
……
Type description and Primitive declaration
[ Specification ]
Body of main program
[ Program implementation ]
Primitive Implementation (basic operation)
6 1/23/2019
Here, we actually have
CCH1D4-STRUKTUR DATA
The Goal of ADT is to separates between
specification and implementation
ADT itself is the Specification part that contains
TYPE declaration and PRIMITIVE specification
7 1/23/2019
Abstract Data Type
CCH1D4-STRUKTUR DATA
Basic Writing Stye : 1 file ADT Style : At least 3 files
Header / type declaration
Primitive specification
Main / body program
ADT style Algorithm
8 1/23/2019
Change the basic style
CCH1D4-STRUKTUR DATA
Type student < …
>
Dictionary
……
function add_student(…)
……
Algorithm
……
……
Function add_student( … )
……
Function delete_student( … )
……
Procedure …… ……
……
Type student < …
>
function add_student(…)
function delete_student(…)
Function add_student( … )
……
Function delete_student( … )
……
Algorithm
……
……
9 1/23/2019
Connectivity Between Modules
CCH1D4-STRUKTUR DATA
Interface
(Implementation)
Header/Type
declaration
compile
implement
specify
Primitive
specification
Security
– user only needs to know the specifications of features
without the need to be given detailed implementation of
these features.
10 1/23/2019
Why we use ADT?
CCH1D4-STRUKTUR DATA
Interface
(main program)
ADT students
There
are 4
menus
I can add,
edit, or
delete data
Don’t need
to know how
they do it
Reusability
– Suppose we’re going to build another information system
that happens also use students record (add, edit, delete)
– We don’t need to code the ADT again, we can use what we
already have
11 1/23/2019
Why we use ADT?
CCH1D4-STRUKTUR DATA
IS 2
Interface 2
(main program 2)
Interface 1
(main program 1)
ADT students
IS 1
Question?
1/23/2019
12
DRY Principles
Don't repeat yourself
“Every piece of knowledge must have a single,
unambiguous, authoritative representation within
a system”
– When the DRY principle is applied successfully, a
modification of any single element of a system does not
require a change in other logically unrelated elements
1/23/2019
13
Task/Exercise : Clock ADT
Create a Clock ADT (Clock.h) to store time (hour,
minute, and second)
1/23/2019
14
TYPE Hour : integer {0..23}
TYPE Minute : integer {0..59}
TYPE Second : integer {0..59}
TYPE Clock :
<
HH : Hour,
MM: Minute,
SS : Second;
>
Task/Exercise : Clock ADT
Primitive for Clock.h
Validator
– Function IsValid(HH,MM,SS: integer)  boolean
– { return true if 0≤HH≤23, and 0≤MM≤59, and 0≤MM≤59 }
Constructor
– Function MakeClock(HH, MN, SS: integer)  clock
– { return clock created from input }
1/23/2019
15
Task/Exercise : Clock ADT
Selector
– Function GetHour(c : clock)  hour
 c.HH
– Function GetMinute(c : clock)  minute
– Function GetSecond(c : clock)  second
Value changer
– Procedure SetHour(In/Out c : clock, newHH: integer)
c.HH  newHH
– Procedure SetMinute(In/Out c : clock, newMM: integer)
– Procedure SetSecond(In/Out c : clock, newSS: integer)
1/23/2019
16
Task/Exercise : Clock ADT
Relational Operation
– Function IsEqual (c1 : clock, c2 :clock)  Boolean
 c1=c2
Arithmetic Operation
– Function AddClock (c1 : clock, c2 :clock)  clock
Output Process
– Procedure PrintClock ( c : clock );
1/23/2019
17
Task/Exercise : Clock ADT
Create the Implementation of Clock ADT
(Clock.cpp)
Create the Driver application to try the
implementation (Main.cpp)
– Example :
– c1  MakeClock(2,30,4)
– c2  MakeClock(6,0,0)
– c3  IsEqual (c1, c2 )
– output(GetHours(c1))
1/23/2019
18
1/23/2019
19
Clock ADT
Implementation Diagram of Clock ADT
//Clock.h
//TYPE Declaration
//PRIMITIF Declaration
//Clock.Cpp
//PRIMITIF
Implementation
//Main.Cpp
//Driver ADT Jam
20 1/23/2019

More Related Content

Similar to Slide ADT-modularity and data abstraction.pdf (20)

PPT
Data Structures: Introduction_______.ppt
smartashammari
 
PPT
DSA___________________SSSSSSSSSSSSSS.ppt
smartashammari
 
PPT
chapter1
Awud Auwal
 
PDF
Cs8391 notes rejinpaul
Dharmaraj Prof and Head CSE Coimbatore
 
PPT
14396822
HaymanotTadese
 
PPT
Chapter 1 - Introduction to Data Structure.ppt
NORSHADILAAHMADBADEL
 
PPT
Object oriented programming using c++
Hoang Nguyen
 
PPT
data structures algorithm-AVL tresss.ppt
Phanibabu Komarapu
 
PPTX
DS 2024 Lecturde dcdcdcdcdcdcd3 & 4.pptx
BilalAshfaqAhmed2
 
PPT
Data_Structure With C_LECTURE ONE PPT123
deepikadalvi18
 
PPT
DAta structure and algorithm presentation
RavikumarP53
 
PPTX
data structures and its importance
Anaya Zafar
 
PPT
data structure
hashim102
 
PPTX
DS Module 1.pptx
sarala9
 
PPT
Data Structures and Algorithms en anglais
dewezstefan1
 
PPTX
Introduction to data_structure
Ashim Lamichhane
 
PPTX
DS Module 1.pptx
SaralaT3
 
PPT
Introduction - Data Structures and Algorithms.ppt
JayaKamal
 
PDF
Data structures and algorithms short note (version 14).pd
Nimmi Weeraddana
 
PPT
Introduction To Data Structures.ppt
NALESVPMEngg
 
Data Structures: Introduction_______.ppt
smartashammari
 
DSA___________________SSSSSSSSSSSSSS.ppt
smartashammari
 
chapter1
Awud Auwal
 
14396822
HaymanotTadese
 
Chapter 1 - Introduction to Data Structure.ppt
NORSHADILAAHMADBADEL
 
Object oriented programming using c++
Hoang Nguyen
 
data structures algorithm-AVL tresss.ppt
Phanibabu Komarapu
 
DS 2024 Lecturde dcdcdcdcdcdcd3 & 4.pptx
BilalAshfaqAhmed2
 
Data_Structure With C_LECTURE ONE PPT123
deepikadalvi18
 
DAta structure and algorithm presentation
RavikumarP53
 
data structures and its importance
Anaya Zafar
 
data structure
hashim102
 
DS Module 1.pptx
sarala9
 
Data Structures and Algorithms en anglais
dewezstefan1
 
Introduction to data_structure
Ashim Lamichhane
 
DS Module 1.pptx
SaralaT3
 
Introduction - Data Structures and Algorithms.ppt
JayaKamal
 
Data structures and algorithms short note (version 14).pd
Nimmi Weeraddana
 
Introduction To Data Structures.ppt
NALESVPMEngg
 

More from septiara5 (20)

PPTX
Introduction to Relational Model and SQL- SCD.pptx
septiara5
 
PPTX
basic concept and definition- sistem basis data.pptx
septiara5
 
PPTX
pendidikan karakter____Pertemuan 3 - Victim Vs Creator Mindset-RSC (1).pptx
septiara5
 
PPTX
pendidikan karakter____Pengenalan MK Pembentukan Karakter (1).pptx
septiara5
 
PDF
pendidikan karakter__02 - Personality-SCD (1).pdf
septiara5
 
PPTX
MK STD Materi Graph ver Final by FSV 2020-HUI.pptx
septiara5
 
PDF
Detail Multi Linked List 1-N__Detail Multi Linked List 1-N.pdf
septiara5
 
PPTX
Graf - Teori Dasar-HUI - Basic Theory.pptx
septiara5
 
PPTX
Graf-Representasi Graf-HUI_Representation graf-HUI.pptx
septiara5
 
PPTX
Graf - Penelusuran Graf-HUI-Graf-Graf.pptx
septiara5
 
PDF
2. Software Testing Life Cycle - Siklus Hidup Pengujian Perangkat Lunak.pdf
septiara5
 
PDF
1.PENGUJIAN PERANGKAT LUNAK - SOFTWARE TESTING.pdf
septiara5
 
PDF
5.Pengujian Black box-Black box testing.pdf
septiara5
 
PDF
4.Test Case-Test Case-Test Case-Test Case.pdf
septiara5
 
PDF
3.Dasar dan Prinsip Testing-Basic Testing and Principles.pdf
septiara5
 
PDF
Software Testing Life Cycle-Software Testing Life Cycle.pdf
septiara5
 
PDF
pendahuluan-PENGUJIAN_PERANGKAT_LUNAK.pdf
septiara5
 
PPTX
06 Review Data Anomalies and Functional Dependencies.pptx
septiara5
 
PDF
01__Introduction _to_Database_konsep dasar.pdf
septiara5
 
PPTX
Introduction to Database_konsep dasar basis data.pptx
septiara5
 
Introduction to Relational Model and SQL- SCD.pptx
septiara5
 
basic concept and definition- sistem basis data.pptx
septiara5
 
pendidikan karakter____Pertemuan 3 - Victim Vs Creator Mindset-RSC (1).pptx
septiara5
 
pendidikan karakter____Pengenalan MK Pembentukan Karakter (1).pptx
septiara5
 
pendidikan karakter__02 - Personality-SCD (1).pdf
septiara5
 
MK STD Materi Graph ver Final by FSV 2020-HUI.pptx
septiara5
 
Detail Multi Linked List 1-N__Detail Multi Linked List 1-N.pdf
septiara5
 
Graf - Teori Dasar-HUI - Basic Theory.pptx
septiara5
 
Graf-Representasi Graf-HUI_Representation graf-HUI.pptx
septiara5
 
Graf - Penelusuran Graf-HUI-Graf-Graf.pptx
septiara5
 
2. Software Testing Life Cycle - Siklus Hidup Pengujian Perangkat Lunak.pdf
septiara5
 
1.PENGUJIAN PERANGKAT LUNAK - SOFTWARE TESTING.pdf
septiara5
 
5.Pengujian Black box-Black box testing.pdf
septiara5
 
4.Test Case-Test Case-Test Case-Test Case.pdf
septiara5
 
3.Dasar dan Prinsip Testing-Basic Testing and Principles.pdf
septiara5
 
Software Testing Life Cycle-Software Testing Life Cycle.pdf
septiara5
 
pendahuluan-PENGUJIAN_PERANGKAT_LUNAK.pdf
septiara5
 
06 Review Data Anomalies and Functional Dependencies.pptx
septiara5
 
01__Introduction _to_Database_konsep dasar.pdf
septiara5
 
Introduction to Database_konsep dasar basis data.pptx
septiara5
 
Ad

Recently uploaded (20)

PPTX
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
EC3551-Transmission lines Demo class .pptx
Mahalakshmiprasannag
 
PDF
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PPTX
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
PPTX
Innowell Capability B0425 - Commercial Buildings.pptx
regobertroza
 
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
EC3551-Transmission lines Demo class .pptx
Mahalakshmiprasannag
 
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Thermal runway and thermal stability.pptx
godow93766
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Design Thinking basics for Engineers.pdf
CMR University
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
Innowell Capability B0425 - Commercial Buildings.pptx
regobertroza
 
Ad

Slide ADT-modularity and data abstraction.pdf

  • 2. describes a program organized into loosely coupled, highly cohesive modules” – Carrano and Prichard, p. 7 “a technique that keeps the complexity of a large program manageable by systematically controlling the interaction of its components” – Carrano and Prichard, p. 106 2 1/23/2019 Modularity CCH1D4-STRUKTUR DATA
  • 3. Modularity is the degree to which a system's components may be separated and recombined Here we will know about Abstract Data Type (ADT) – to understand better about ADT, let’s see the illustration 3 1/23/2019 In Short : CCH1D4-STRUKTUR DATA
  • 4. Suppose we will make an information System to store students record There are 4 menus – Add new data – Delete data – Edit data – View stored data 4 1/23/2019 Student Information System CCH1D4-STRUKTUR DATA
  • 5. Basic Algorithm Writing Style 5 1/23/2019 What we usually do? CCH1D4-STRUKTUR DATA Type student < … > Dictionary …… function add_student(…) …… Algorithm …… …… Function add_student( … ) …… Function delete_student( … ) …… Procedure …… …… …… Type description of student, name, id, class, etc. Declaring Variables and name of functions that will be used in main program Main program, contains menu, interface, etc. The main program will use the functions available or has been specified Function specification, basic operation for student All in one file (one script)
  • 6. 3 parts of program or 3 modules Type student < … > Dictionary …… function add_student(…) …… Algorithm …… …… Function add_student( … ) …… Function delete_student( … ) …… Procedure …… …… …… Type description and Primitive declaration [ Specification ] Body of main program [ Program implementation ] Primitive Implementation (basic operation) 6 1/23/2019 Here, we actually have CCH1D4-STRUKTUR DATA
  • 7. The Goal of ADT is to separates between specification and implementation ADT itself is the Specification part that contains TYPE declaration and PRIMITIVE specification 7 1/23/2019 Abstract Data Type CCH1D4-STRUKTUR DATA
  • 8. Basic Writing Stye : 1 file ADT Style : At least 3 files Header / type declaration Primitive specification Main / body program ADT style Algorithm 8 1/23/2019 Change the basic style CCH1D4-STRUKTUR DATA Type student < … > Dictionary …… function add_student(…) …… Algorithm …… …… Function add_student( … ) …… Function delete_student( … ) …… Procedure …… …… …… Type student < … > function add_student(…) function delete_student(…) Function add_student( … ) …… Function delete_student( … ) …… Algorithm …… ……
  • 9. 9 1/23/2019 Connectivity Between Modules CCH1D4-STRUKTUR DATA Interface (Implementation) Header/Type declaration compile implement specify Primitive specification
  • 10. Security – user only needs to know the specifications of features without the need to be given detailed implementation of these features. 10 1/23/2019 Why we use ADT? CCH1D4-STRUKTUR DATA Interface (main program) ADT students There are 4 menus I can add, edit, or delete data Don’t need to know how they do it
  • 11. Reusability – Suppose we’re going to build another information system that happens also use students record (add, edit, delete) – We don’t need to code the ADT again, we can use what we already have 11 1/23/2019 Why we use ADT? CCH1D4-STRUKTUR DATA IS 2 Interface 2 (main program 2) Interface 1 (main program 1) ADT students IS 1
  • 13. DRY Principles Don't repeat yourself “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system” – When the DRY principle is applied successfully, a modification of any single element of a system does not require a change in other logically unrelated elements 1/23/2019 13
  • 14. Task/Exercise : Clock ADT Create a Clock ADT (Clock.h) to store time (hour, minute, and second) 1/23/2019 14 TYPE Hour : integer {0..23} TYPE Minute : integer {0..59} TYPE Second : integer {0..59} TYPE Clock : < HH : Hour, MM: Minute, SS : Second; >
  • 15. Task/Exercise : Clock ADT Primitive for Clock.h Validator – Function IsValid(HH,MM,SS: integer)  boolean – { return true if 0≤HH≤23, and 0≤MM≤59, and 0≤MM≤59 } Constructor – Function MakeClock(HH, MN, SS: integer)  clock – { return clock created from input } 1/23/2019 15
  • 16. Task/Exercise : Clock ADT Selector – Function GetHour(c : clock)  hour  c.HH – Function GetMinute(c : clock)  minute – Function GetSecond(c : clock)  second Value changer – Procedure SetHour(In/Out c : clock, newHH: integer) c.HH  newHH – Procedure SetMinute(In/Out c : clock, newMM: integer) – Procedure SetSecond(In/Out c : clock, newSS: integer) 1/23/2019 16
  • 17. Task/Exercise : Clock ADT Relational Operation – Function IsEqual (c1 : clock, c2 :clock)  Boolean  c1=c2 Arithmetic Operation – Function AddClock (c1 : clock, c2 :clock)  clock Output Process – Procedure PrintClock ( c : clock ); 1/23/2019 17
  • 18. Task/Exercise : Clock ADT Create the Implementation of Clock ADT (Clock.cpp) Create the Driver application to try the implementation (Main.cpp) – Example : – c1  MakeClock(2,30,4) – c2  MakeClock(6,0,0) – c3  IsEqual (c1, c2 ) – output(GetHours(c1)) 1/23/2019 18
  • 19. 1/23/2019 19 Clock ADT Implementation Diagram of Clock ADT //Clock.h //TYPE Declaration //PRIMITIF Declaration //Clock.Cpp //PRIMITIF Implementation //Main.Cpp //Driver ADT Jam