1 - Konsep Obyek Dan Class

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

KONSEP OBYEK DAN CLASS

BAYU PRIYAMBADHA
TUJUAN PERKULIAHAN

• Memahami konsep Obyek dan Class


• Memahami 4 pilar utama OOP
• Memahami perbedaan pendekatan Obyek dan Prosedural/Terstruktur
AGENDA

• Object
• Class
• 4 Pilars of OOP
• OOP Vs Procedural (Structural)
Object???
OBJECT

• an object is a thing.
• tangible and intangible, that we can imagine.
• A program written in object-oriented style will consist of interacting objects.

Truck Chemical Process Linked List


Class???
CLASS

• Blueprints for an object and are the actual code Professor


- name
that defines the properties and methods.
- employeeID : UniqueId
• The definition of objects.
- hireDate
- status
- discipline
• A kind of mold or template that dictates what - maxLoad
objects can and cannot do.
+ submitFinalGrade()
• An object is called an instance of a class. + acceptCourseOffering()
+ setMaxLoad()

• An object is belongs to a class.


+ takeSabbatical()
+ teachClass()
Abstraction
4 PILARS OF OOP

Encapsulation

Modularity
Object Orientation

Hierarchy
ABSTRACTION

• The essential characteristics of an entity that distinguishes it from all other kinds of entities.
• Defines a boundary relative to the perspective of the viewer.
• Example :
• When you are at school, then you are a"Student". When you are at work, you are an "Employee".
When you are at government institution, you can be viewed as a "Citizen". So it boils down to what in
what context are we looking at an entity/object. So if I am modelling a Payroll System, I will look at you
as an Employee(PRN, Full Time/Part Time, Designation). If am modelling a Course Enrollment System, then I
will consider your aspects and characteristics as a Student(Roll Number, Age, Gender, Course Enrolled).
And if I am modelling a Social Security Information System then I will look at your details as aCitizen(like
DOB, Gender, Country Of Birth, etc.)
ENCAPSULATION

• Hides implementation from clients.


• Clients depend on interface.
• Encapsulation is often referred to as “information hiding,” making it possible
for the clients to operate without knowing how the implementation implements
the interface.
MODULARITY

• Breaks up something complex into manageable pieces.


• Helps people understand complex systems. Billing
System

Course
Catalog
System

Course Registration
System Student
Management
System
HIERARCHY
Increasing Asset
abstraction

BankAccount Security RealEstate

Decreasing Savings Checking Stock Bond


abstraction
Elements at the same level of the
hierarchy should be at the same level of
abstraction.
IDENTIFY ALL THE OBJECTS!!!

• Harry survived with only a lightning-shaped scar on his forehead as a


memento of the attack, and Voldemort disappeared afterwards. (Ganjil)
• Ron's younger sister, Ginny Weasley, enrolls in her first year at Hogwarts, and
finds an old notebook which turns out to be Voldemort's diary from his school
days. (Genap)
Terima Kasih…

You might also like