0% found this document useful (0 votes)
72 views15 pages

Chapter2 OOPConcepts

This document discusses key object-oriented programming concepts including abstraction, cohesion, encapsulation, and information hiding. Abstraction creates a layer between an object and user, showing only important details. Cohesion means aspects of an object "fit together" well, while high cohesion avoids putting too many functionalities in one object. Encapsulation places boundaries around an object's properties and functionalities to protect data and hide information. Information hiding isolates clients from requiring intimate design knowledge or being affected by changes. Access control and restricting access/modification of data through accessors and mutators help achieve information hiding.

Uploaded by

pam yasstos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views15 pages

Chapter2 OOPConcepts

This document discusses key object-oriented programming concepts including abstraction, cohesion, encapsulation, and information hiding. Abstraction creates a layer between an object and user, showing only important details. Cohesion means aspects of an object "fit together" well, while high cohesion avoids putting too many functionalities in one object. Encapsulation places boundaries around an object's properties and functionalities to protect data and hide information. Information hiding isolates clients from requiring intimate design knowledge or being affected by changes. Access control and restricting access/modification of data through accessors and mutators help achieve information hiding.

Uploaded by

pam yasstos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Chapter 2

Object-Oriented
Programming Concepts

FALL22
Safae Bourhnane
Chapter ILOs

 Understand the main object-


oriented concepts:
• Abstraction

• Cohesion

• Encapsulation

• Information hiding
Abstraction

 What is Abstraction?

 Creates a layer between the object


and the user
• Show only what is important to
the user
• The object is treated as a black
box
• What is wrong?
Abstraction

Examples
• Washing machine
• Coffee maker
• Computer

Other examples?
Cohesion
 Problem: putting too many functionalities into one object

 Cohesion means that various aspects of an object “fit together”


• Cohesion: interaction within a module
• Coupling: interaction between modules
Cohesion
 What is wrong?

 What is the solution?


Cohesion
 High Cohesion
Encapsulation

Allows the object to place boundaries around its properties and


functionalities

Does encapsulation ensure data protection


Question: and information hiding?
Encapsulation
 What is wrong?
Encapsulation
 How to make it more Object-Oriented?
Information Hiding
 Hiding of critical design decisions

 Difficult design decisions and decisions that are likely to change

 Hiding information isolates clients from requiring intimate knowledge of the design to
use a module, and from the effects of changing those decisions.
Information Hiding
 What is wrong?
Information Hiding – Access Control

The class has to expose only what is necessary to the Why do we need access control?
client programmer and keeps everything else hidden:
Access Control.

- To prevent client programmers from


accessing sensitive data.
- To allow the library designer to change
the internal workings of the class without
worrying about how it will affect the
client programmer.
Access Control – A look ahead
 Java makes use of explicit keywords to set boundaries for the classes, e.g. public,
private

• public means that the element can be available to everyone


• private means that no one has access to the element except the creator of the class.
Information Hiding
 Restrict access and modification of internal data through the use of accessors and
mutators

• Accessors/getters: public methods that give information about the state of the object

• Mutator/setter: public methods used to modify the state of an object without explicitly
showing how data gets modified

You might also like