SWC2333 Topic 1 OOP
SWC2333 Topic 1 OOP
ORIENTED PROGRAMMING
TOPIC 1 – OBJECT ORIENTED
PROGRAMMING (OOP)
2
1.1. Introduction to object
3
1.1. Introduction to object
4
1.1. Introduction to object
5
1.1. Introduction to object
7
1.1. Introduction to object
8
1.1. Introduction to object
10
1.2. Elements of an object
(continue)
▪ Identity: An object's identity is a quality that makes it
distinct from all other objects.
▪ Responsibility: It is the function of an object that it
performs within the system.
11
1.2. Elements of an object
12
1.2. Elements of an object
What is an Attribute?
▪ An attribute refers to a data member or a property
associated with an object or a class
▪ They define the state of an object and can have different
values for different instances of the same class
▪ Attributes can be of various data types, such as integers,
strings, Booleans, or even other objects
13
1.3 Characteristics of OOP
14
1.3 Characteristics of OOP Classes and Objects
▪ A class is a template that consists of the data members or
variables and functions and defines the properties and
methods for a group of objects.
▪ The compiler does not allocate memory whenever you define a
class. Example:
You can define a class called Vehicle. Its data fields can be
vehicle_name, model_number, color, date_of_manufacture, etc.
15
1.3 Characteristics of OOP Abstraction
▪ Object Oriented Programming abstraction exposes only the
essential information of an object to the user and hides the
other details.
▪ In OOP, implement abstraction is by using classes that group
the data members and function together.
▪ Inside classes, the access specifiers are used for its members
to control how they are visible to the outside world. (public,
private, protected, and default (package-private))
16
1.3 Characteristics of OOP Inheritance
▪ Allows a class to inherit the properties and
methods of another class called the parent
class, the base class, or the super-class.
▪ The class that inherits is called the child
class or sub-class.
▪ It helps to avoid duplication of codes by
allowing code reuse as you need not define
the same methods and properties present in
a super-class in the sub-classes again. The
sub-class can simply inherit them.
17
1.3 Characteristics of OOP Polymorphism
▪ Means ‘having many forms’. In simple words, we can define
Java Polymorphism as the ability of a message to be displayed
in more than one form.
▪ Allows you to define one interface and have multiple
implementations.
18
1.3 Characteristics of OOP Encapsulation
▪ Enclosing the data/variables and the methods for manipulating the
data into a single entity called a class. It helps to hide the internal
implementation of the functions and state of the variables, promoting
abstraction.
▪ Allows you to define one interface and have multiple implementations.
19
Asiah is going to build a pot with the use
TO CONCLUDE ABOUT OOP of blocks. Blocks are a kind of
measurement units like height, radius,
& OBJECT…..
and shape by default. These properties
are there by default, which means if you
use a block, it has some dimensions
associated with it. Now, some other
crucial properties are not yet assigned,
like color, material, and price. So,
OBJECTS are nothing but pot. We build an
object by assigning values to the
properties when we need them. Blocks is
nothing but the templates of the object.
There we write how the object should
appeal (means look like) and how the
actions will take place. In Java, we call it a
class.
20
1.4 Benefits of OOP
1. Re-usability
▪ It means reusing some facilities rather than building them
again and again. This is done with the use of a class. We
can use it ‘n’ number of times as per our need.
2. Data Redundancy
▪ If a user wants a similar functionality in multiple classes,
he/she can go ahead by writing common class definitions
for similar functionalities and inherit them.
21
1.4 Benefits of OOP
3. Code Maintenance
▪ easy and time-saving to maintain and modify the
existing codes by incorporating new changes into
them.
4. Security
▪ With the use of data hiding and abstraction
mechanism, we are filtering out limited data to
exposure.
22
1.4 Benefits of OOP
5. Design Benefits
▪ Designing and fixing things easily and eliminating the risks (if any) -
better designs and fewer flaws.
6. Better productivity
▪ More work done, finishing a better program, having more inbuilt
features, and easier reading, writing and maintaining. Can stitch new
software objects to make completely new programs. A good number of
libraries with useful functions in abundance make it possible.
Read More:-
https://canvas.rku.ac.in/courses/3333/pages/benefits-of-object-
oriented-programming
23
SUMMARY
24
SUMMARY
Feel free to read more:
https://www.naukri.com/code360/library/what-is-an-object-in-object-
oriented-programming-oops
https://medium.com/@saket_89496/state-property-behavior-and-
identity-explained-in-simple-words-b00b935cbf02
https://www.naukri.com/code360/library/what-are-the-features-of-
object-oriented-programming
https://www.geeksforgeeks.org/polymorphism-in-java/
25
“Object-oriented programming offers a
sustainable way to write spaghetti code. It lets
you accrete programs as a series of patches.
Large organizations always tend to develop
software this way, and I expect this to be as
true in a hundred years as it is today.”
― Paul Graham, Hackers & Painters: Big Ideas from the
Computer Age
26