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]
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.
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
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
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.
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
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.
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
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.
SOFTWARE EVOLUTION
Layers of software technology
Object Oriented Programming
Procedure Programming
Assembly Language
Machine Language
1, 0
A LOOK AT PROCEDURE-ORIENTED PROGRAMMING
Main Program
Function 1
Function 8Function 6
Function 4 Function 5
Function 3Function 2
Function 7
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
BASIC CONCEPTS OF OOP
OBJECTS CLASSES DATA ABSTRACTION ENCAPSULATION INHERITANCE POLYMORPHISM DYNAMIC BINDING MESSAGE PASSING
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.
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
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
Representing notations:
Object: STUDENT
DATA: Name Date-of-Birth Marks ….
FUNCTIONS: Total Average Display ….
STUDENTName
Date-of-BirthMarks
Total
Average
Display
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).
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
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.
Bird
Attributes: Feathers Lay eggs
Flying Bird
Attributes: _________ _________
Non Flying Bird
Attributes: _________
Robin
Attributes: _________ _________
Swallow
Attributes: _________ _________
Penguin
Attributes: _________ _________
Kiwi
Attributes: _________ _________
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
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.
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