Top Banner
BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++
30

BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Dec 13, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

BAHASA PEMROGRAMAN 2

OBJECT ORIENTED PROGRAMMINGUsing C++

Page 2: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Tentang saya

Wahyu S. J. Saputra, S.Kom S1 Teknik Informatika UPN “Veteran” Jatim 2004 - 2009 Email: [email protected]

Tugas: [email protected]

Page 3: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Tujuan

UmumMahasiswa memahami paradigma pemrograman berorientasi objek dalam lingkungan bahasa C++.

Khusus Mahasiswa memahami konsep class dan object. Mahasiswa memahami konsep constructor dan

destructor. Mahasiswa memahami konsep polymorphism. Mahasiswa memahami konsep inheritance.

Page 4: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Buku Referensi

Object Oriented Programming with C++, E. Balagurusamy, Tata McGraw-Hill, 1995.

Internet. Bahan Kuliah : map ke server LAN

\\172.16.34.209\kuliah

Page 5: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Penilaian

UTS UAS Tugas & Quiz Kehadiran

Page 6: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Satuan Acara Perkuliahan1. Kontrak Kuliah + Pengenalan Dasar OOP2. Class dan Object 13. Class dan Object 24. Class dan Object 35. Constructors dan Destructors 16. Constructors dan Destructors 27. Demo Program/ Quiz8. UTS9. Polymorphism/ Overloading10. Inheritance 111. Inheritance 212. Pointer dan Virtual Function13. OO Development + Quiz14. Demo Program 1 Kelompok 1 – 5.15. Demo Program 2 Kelompok 6 – 10.16. UAS

Page 7: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

CATATAN

Toleransi keterlambatan hadir adalah 30 menit.

Mahasiswa harus berpakaian rapi dengan baju berkerah dan bersepatu.

Tidak ada toleransi untuk kecurangan selama ujian tulis.

Ujian/ tugas susulan akan diberikan dengan menunjukkan surat keterangan yang jelas.

Page 8: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Case Studies

1. FRS Online2. SIM Nilai Praktikum3. Penjualan Voucher HP4. Tarif Jasa Parkir5. SIM Gaji Pegawai6. Billing Warnet7. Pendaftaran Mahasiswa Baru8. SIM Hewan di Kebun Binatang9. Penjualan Sepeda Motor10. Rental VCD

Page 9: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Introduction to

Object Oriented Programming

Concepts

Page 10: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Edsger Dijkstra

The machines have become several orders of magnitude more powerful!

As long as there were no machines, programming was no problem at all;

When we had a few weak computers, programming became a mild problem, and

Now we have gigantic computers, programming has become an equally gigantic problem.

Page 11: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

SOFTWARE CRISIS

60% projects had schedule overruns, 50% projects had cost overruns, 45% projects could not be used, 29% projects was never delivered, and 19% projects had to be reworked to be

used. *USA contractors surveyed

Page 12: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Object-oriented programming addresses those problem by strongly emphasizing modularity in software.

Modul is a component of a larger system, and operate within that system independently from the operations of the other components.

Page 13: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

SOFTWARE EVOLUTION

Layers of software technology

Object Oriented Programming

Procedure Programming

Assembly Language

Machine Language

1, 0

Page 14: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

A LOOK AT PROCEDURE-ORIENTED PROGRAMMING

Main Program

Function 1

Function 8Function 6

Function 4 Function 5

Function 3Function 2

Function 7

Page 15: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Global Data Global Data

Function 1

Local Data

Function 1

Local Data

Function 1

Local Data

Some characteristics:• Emphasis is on doing things (algorithms)• Large programs are devided into smaller programs known as function/ subrutin• Most of the function share global data• Data move openly around the system from function to function

Page 16: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

OOP PARADIGM

DATA

FUNCTIONS

OBJECT A

DATA

FUNCTIONS

OBJECT C

DATA

FUNCTIONS

OBJECT B

Page 17: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

BASIC CONCEPTS OF OOP

OBJECTS CLASSES DATA ABSTRACTION ENCAPSULATION INHERITANCE POLYMORPHISM DYNAMIC BINDING MESSAGE PASSING

Page 18: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Some of OOP’s striking features:

Emphasis is on data rather than procedure.

Programs are divided into objects.

Data structures are designed such that they

characterize the objects.

Functions are tied together in the data

structures.

Data is hidden and can not be accessed by

external functions.

Page 19: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

CLASSES

Is the user defined data types A collection of objects of similar type Example:

Object mango, apple, and orange is member of class fruit

Object TF, TI, TK, TP is member of class JurusanObject jip, sedan, bus, truk is member of class

mobil

Page 20: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

OBJECTS

Is the variables of program Have a life cycle. They can be created and

destroyed. Interacts by sending message to one

another Contains data and code/ function to

manipulate the data

Page 21: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Representing notations:

Object: STUDENT

DATA: Name Date-of-Birth Marks ….

FUNCTIONS: Total Average Display ….

STUDENTName

Date-of-BirthMarks

Total

Average

Display

Page 22: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

DATA ABSTRACTION

The act of representing essential features without including the background details or explanations.

Defined as list of attributes and functions. Known as Abstract Data Types (ADT).

Page 23: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

ENCAPSULATION

Wrapping up of data and functions into a single unit (called class).

The data is not accessible to the outside world and only functions which are wrapped in the class can access it.

Insulation of the data from direct access by the program is called data hiding

Page 24: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

INHERITANCE

Is the process by which objects of one class acquire the properties of objects of another class.

Supports the concepts of hierarchical classification.

Provides the idea of reusability. Example: the bird robin is a part of the class

flying bird which is again a part of the class bird.

Page 25: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Bird

Attributes: Feathers Lay eggs

Flying Bird

Attributes: _________ _________

Non Flying Bird

Attributes: _________

Robin

Attributes: _________ _________

Swallow

Attributes: _________ _________

Penguin

Attributes: _________ _________

Kiwi

Attributes: _________ _________

Page 26: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

POLYMORPHISM

The ability to take more than one form. An operation may exhibit different behaviour in

different instances depends upon the data types used in the operation.

Example: addition operation If two numbers, will generate a sum If two strings, will generate a concatenation

Extensively used in implementing inheritance

Page 27: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

Shape

Draw ( )

Box Object

Draw ( )

Triangle Object

Draw ( )

Circle Object

Draw ( )

Page 28: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

DYNAMIC BINDING

The code asociated with a given procedure call is not known until the time of the call at run time.

Associated with polymorphism and inheritance. Example: (above diagram) Unique to each

object and so the draw procedure will be redefined in each class that defines the object.

At run-time, the code matching the object under current reference will be called.

Page 29: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

MESSAGE PASSING

Object oriented program consist of a set of objects communicate with each.

Steps: Creating classes that define objects and their behaviour. Creating objects from class definitions. Establishing communication among objects.

Objects communicate with one another by sending and receiving information.

Message passing involves: object’s name, function’s name (message) and information

Page 30: BAHASA PEMROGRAMAN 2 OBJECT ORIENTED PROGRAMMING Using C++

BENEFITS OF OOP

Through inheritance, we can eliminate redundant code and extend the use of existing classes.

The principle of data hiding helps the programmer to build secure programs.

Can be easily upgraded from small to large systems.

Software complexity can be easily managed.