SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
Lecturer:
Session-3   Kalamullah Ramli

            Electrical Engineering Dept.
            University of Indonesia




Object Oriented Programming Principles
Object-Oriented Programming:
A New Programming Paradigm…
  What is Matlab's programming paradigm?
  Matlab is procedural: the focus is on the
  functions (procedures)

  What is the programming paradigm in OOP?
  As the name suggests, in OOP the focus is on
                         OBJECTS
  This doesn't say much unless we understand
  what we mean with the term Object… So
  let's move on.
OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                        Ing.                Ramli,         Slide - 2
Objects Combine Properties & Behavior [1/2]

    Remember following Structures:
      person.firstname = 'John';
      person.lastname = 'Leonard';
      person.address1 = '803 Shallowford
      Lane';
      person.city = 'Peachtree City';
      person.state = 'GA';
      person.zip = '30269-4289';

    A structure contains data in an organized fashion.


 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 3
Objects Combine Properties & Behavior [2/2]

     If we add functions or methods to a structure, it
     becomes an object:
          person.print_address();
          person.set_lastName('Paredis');




 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 4
More Examples of Objects [1/2]

    Car:
        Properties: color, speed, fuel consumption, HP…
        Behaviors: start, stop, turning, …
    Triangle:
        Properties: area, perimeter, linestyle, location,…
        Behaviors: translate, rotate, shrink, flip,…
    Date:
        Properties: year, month, day, …
        Behaviors: setDate, getMonth, isGreater, …




 OOP Lecture 2004       Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                             Ing.                Ramli,         Slide - 5
More Examples of Objects [1/2]

    Properties: information about the object
    Behaviors: methods to set, get and process
    properties

     Combining properties and behaviors in objects is
                         called
                     Encapsulation




 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 6
Objects Combine Properties and Behavior:
So What? Why should we care? [1/2]


   Black Box Philosophy:
   Objects perform computation                                Messages
   by making requests of each
   other through the passing of
   messages

                                                                Code
   The only way to interact with
   an object is through its                                                          Data
   methods!

                                           http://java.sun.com/docs/books/tutorial/java/concepts/object.html
 OOP Lecture 2004                          http://catalog.com/softinfo/objects.html
                    Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,                                    Slide - 7
Objects Combine Properties and Behavior:
So What? Why should we care? [2/2]

    This is called Information Hiding
    (the data is hidden from the user)

    The collection of all methods is called
    the interface of the object




                                           http://java.sun.com/docs/books/tutorial/java/concepts/object.html
 OOP Lecture 2004                          http://catalog.com/softinfo/objects.html
                    Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,                                    Slide - 8
Encapsulation and Data Hiding [1/2]

   Properties (Variables)
       Speed
       RPM
       Current Gear
   Methods (Functions)
       Braking
       Acceleration
       Turn
       Changing Gears


 OOP Lecture 2004     Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                           Ing.                Ramli,         Slide - 9
Encapsulation and Data Hiding [2/2]

   These methods are independent of how the
   bicycle has been built (hides the
   implementation)
   You can control access to members of an
   object




 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 10
Working with Objects: Messages [1/2]

 Objects perform computation by making
 requests of each other through the passing of
 messages




 Parts of a message –
     The object to which the message is addressed
     The name of the method to perform
     Any parameters needed by the method

 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 11
Working with Objects: Messages [2/2]

 Different objects may respond differently to an
 identical message:
     bicycle.changeGears(lowerGear)
     car.changeGears(lowerGear)


 The same name and the same argument, but a
 different method = POLYMORPHISM

 A method is defined only in the scope of a
 particular type of object, called class
 Polymorphism is also called: function overloading
 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 12
Class and Object [1/2]

  Now that we know what an object is all about,
  let's look at how we can organize these objects
  Class = A blueprint, or prototype, that defines
  the variables and the methods common to all
  objects of a certain kind




                    Objects are individual
                    instances of a class


 OOP Lecture 2004          Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                                Ing.                Ramli,         Slide - 13
Class and Object [2/2]




 House Plans:                          A House:

 the architectural drawings that       The house built from the plans
describe how a house is to be         is an instance of the House Class.
constructed                           The process of building the
                                      house is called Instantiation

 OOP Lecture 2004     Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                           Ing.                Ramli,         Slide - 14
Organizing Objects: Inheritance [1/2]


   Children inherit                                           Super class
   • properties                                               (parent)
   • behaviors

                                                               Sub class
                                                               (child)




 OOP Lecture 2004     Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                           Ing.                Ramli,           Slide - 15
Organizing Objects: Inheritance [2/2]

 Sub class (Child)
  •    A class that is derived from a particular class,
       perhaps with one or more classes in between

 Super class (Parent)
  •    A class from which a particular class is derived,
      perhaps with one or more classes in between

 Inheritance promotes
      Reuse of code
      Better Management of code

 OOP Lecture 2004     Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                           Ing.                Ramli,         Slide - 16
Abstraction in OOP [1/2]

    Abstractions reveal causes and effects, expose
    patterns and frameworks and separate what's
    important from what's not

    Abstraction in programming helps you make your
    ideas concrete in your code without obscuring the
    architecture with details

    In procedural languages:
          structures and functions are abstractions



 OOP Lecture 2004       Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                             Ing.                Ramli,         Slide - 17
Abstraction in OOP [2/2]


  OOP takes abstraction one step further through:
    encapsulation
    data hiding
    polymorphism
    Inheritance




 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 18
Object-Oriented Programming [1/2]

   A Quick Review:
   “OOP is more a way of thinking than just a programming
   technique” – “conceptual tool that you use in thinking how to
   solve a problem”
   Computer objects form the basis
   Objects treated as real life objects
       Identities
       Properties
       Behaviors
   Data and functionality encapsulated in an object
   Data hidden behind methods


 OOP Lecture 2004      Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                            Ing.                Ramli,         Slide - 19
Object-Oriented Programming [2/2]

   Objects organized in class hierarchies: inheritance
   Objects interact through messages – methods
   Polymorphism: the same message has a different meaning for
   different objects




 OOP Lecture 2004      Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                            Ing.                Ramli,         Slide - 20
Benefits of Object Oriented
Programming

 Analysis and Design made easier

 Understanding of code made easier

 Code Reuse

 Ease of maintenance and enhancement

 Simplifies collaboration

 Fewer and shorter design iterations

 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 21
Examples of Programming Languages

 Procedural languages
     C
     FORTRAN
     BASIC
     Pascal


 Object Oriented languages
     C++
     Smalltalk
     Java

 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 22
Assignment#2a: OOP vs Procedural Programming


 Object-Oriented                      Procedural




Due date: Friday, February 27th, 2004

 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 23
Assignment#2b: Object Oriented Philosophy

  “Simulate the functionality of your computer using the
  object oriented philosophy”

  Draw a diagram of the components present in the
  computer. What is the flow of information between
  these components? Leverage from previous lectures.
  Identify the classes and objects that you would need to
  simulate these components. How do these classes
  interact?
  Identify the variables and methods that you would
  assign to each class.
Due Date: Friday, March 5th, 2004

 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 24
References and Additional Reading
    “Object Oriented Programming, ”
    http://www.toodarkpark.net/computers/objc/oop.h
    tml

    “Core Java, ” Cay S. Horstmann and Gary Cornell,
    Sun Microsystems

    “ Thinking in C++, ” Bruce Eckel,
    http://www.mindview.net/Books/TICPP/ThinkingInC
    PP2e.html

    “ Introduction to Object Oriented Programming, ”
    Timothy Budd,
    ftp://ftp.cs.orst.edu/pub/budd/oopintro/3rdEdition
    /info.html

 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 25
Closure

 Learning
 Object oriented programming is more a philosophy than mere
 technique to develop programs…
 This philosophy provides modularity to programs
 Modularity provides openness to change…
 Enables developing complex systems

 Food for Thought
 How will object oriented philosophy help in the future of software
 development?
 How can the object oriented philosophy based on modularity be
 used in your field of specialization?
 What changes are required to adapt this philosophy to your field?


 OOP Lecture 2004     Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                           Ing.                Ramli,         Slide - 26
The End




     QUESTIONS & COMMENTS ?




 OOP Lecture 2004   Dr. –Ing. Ir. Kalamullah Ramli, M.Eng
                         Ing.                Ramli,         Slide - 27

Mais conteúdo relacionado

Mais procurados

Object-Oriented Concepts
Object-Oriented ConceptsObject-Oriented Concepts
Object-Oriented ConceptsAbdalla Mahmoud
 
Introduction of object oriented analysis & design by sarmad baloch
Introduction of object oriented analysis & design by sarmad balochIntroduction of object oriented analysis & design by sarmad baloch
Introduction of object oriented analysis & design by sarmad balochSarmad Baloch
 
OOPs concept and implementation
OOPs concept and implementationOOPs concept and implementation
OOPs concept and implementationSandeep Kumar P K
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Javawiradikusuma
 
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Michael Redlich
 
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,NoidaTeaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,NoidaDr. Sandeep Kumar Singh
 
Object Oriented Analysis And Design
Object Oriented Analysis And DesignObject Oriented Analysis And Design
Object Oriented Analysis And DesignSahil Mahajan
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming ConceptsKwangshin Oh
 
Object Oriented Paradigm
Object Oriented ParadigmObject Oriented Paradigm
Object Oriented ParadigmHüseyin Ergin
 
Object-Oriented Analysis and Design
Object-Oriented Analysis and DesignObject-Oriented Analysis and Design
Object-Oriented Analysis and DesignRiazAhmad786
 
1 Intro Object Oriented Programming
1  Intro Object Oriented Programming1  Intro Object Oriented Programming
1 Intro Object Oriented ProgrammingDocent Education
 
Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyaySaurabh Upadhyay
 

Mais procurados (20)

Object-Oriented Concepts
Object-Oriented ConceptsObject-Oriented Concepts
Object-Oriented Concepts
 
Introduction of object oriented analysis & design by sarmad baloch
Introduction of object oriented analysis & design by sarmad balochIntroduction of object oriented analysis & design by sarmad baloch
Introduction of object oriented analysis & design by sarmad baloch
 
Ooadb
OoadbOoadb
Ooadb
 
OOPs concept and implementation
OOPs concept and implementationOOPs concept and implementation
OOPs concept and implementation
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
 
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
 
Oop concept
Oop conceptOop concept
Oop concept
 
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,NoidaTeaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
 
OOP Basics
OOP BasicsOOP Basics
OOP Basics
 
Object Oriented Analysis And Design
Object Oriented Analysis And DesignObject Oriented Analysis And Design
Object Oriented Analysis And Design
 
Oops slide
Oops slide Oops slide
Oops slide
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming Concepts
 
Object Oriented Paradigm
Object Oriented ParadigmObject Oriented Paradigm
Object Oriented Paradigm
 
Ooad
OoadOoad
Ooad
 
Object-Oriented Analysis and Design
Object-Oriented Analysis and DesignObject-Oriented Analysis and Design
Object-Oriented Analysis and Design
 
Oop basic overview
Oop basic overviewOop basic overview
Oop basic overview
 
1 Intro Object Oriented Programming
1  Intro Object Oriented Programming1  Intro Object Oriented Programming
1 Intro Object Oriented Programming
 
Cs8392 oops 5 units notes
Cs8392 oops 5 units notes Cs8392 oops 5 units notes
Cs8392 oops 5 units notes
 
Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh Upadhyay
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 

Destaque

Platform-independent static binary code analysis using a meta-assembly language
Platform-independent static binary code analysis using a meta-assembly languagePlatform-independent static binary code analysis using a meta-assembly language
Platform-independent static binary code analysis using a meta-assembly languagezynamics GmbH
 
memory organization of a computer
memory organization of a computer memory organization of a computer
memory organization of a computer Ashaduzzaman Kanon
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly LanguageMotaz Saad
 
Assembly Language Lecture 3
Assembly Language Lecture 3Assembly Language Lecture 3
Assembly Language Lecture 3Motaz Saad
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1Motaz Saad
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESDr.YNM
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language BasicsEducation Front
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.parthi_arjun
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGFrankie Jones
 
Ppt on water level indicator
Ppt on water level indicatorPpt on water level indicator
Ppt on water level indicatorpalwinder virk
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)Ashim Saha
 

Destaque (16)

Chapter1
Chapter1Chapter1
Chapter1
 
Platform-independent static binary code analysis using a meta-assembly language
Platform-independent static binary code analysis using a meta-assembly languagePlatform-independent static binary code analysis using a meta-assembly language
Platform-independent static binary code analysis using a meta-assembly language
 
memory organization of a computer
memory organization of a computer memory organization of a computer
memory organization of a computer
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
Assembly Language Lecture 3
Assembly Language Lecture 3Assembly Language Lecture 3
Assembly Language Lecture 3
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Getting started with pic microcontrollers
Getting started with pic microcontrollersGetting started with pic microcontrollers
Getting started with pic microcontrollers
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTES
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
 
Memory organization
Memory organizationMemory organization
Memory organization
 
8086 microprocessor lab manual
8086 microprocessor lab manual8086 microprocessor lab manual
8086 microprocessor lab manual
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
 
Ppt on water level indicator
Ppt on water level indicatorPpt on water level indicator
Ppt on water level indicator
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
 

Semelhante a Chapter3 bag1

Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Nuzhat Memon
 
Object oriented progrmming
Object oriented progrmmingObject oriented progrmming
Object oriented progrmmingAbdul Wahab
 
Lecture 2 cst 205-281 oop
Lecture 2   cst 205-281 oopLecture 2   cst 205-281 oop
Lecture 2 cst 205-281 oopktuonlinenotes
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaMadishetty Prathibha
 
Programming Laboratory Unit 1.pdf
Programming Laboratory Unit 1.pdfProgramming Laboratory Unit 1.pdf
Programming Laboratory Unit 1.pdfswapnilslide2019
 
Object Oriented Programming.pptx
 Object Oriented Programming.pptx Object Oriented Programming.pptx
Object Oriented Programming.pptxShuvrojitMajumder
 
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdfSulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdfSULTHAN BASHA
 
Basics of object oriented programming
Basics of object oriented programmingBasics of object oriented programming
Basics of object oriented programmingNitin Kumar Kashyap
 
Object oriented vs. object based programming
Object oriented vs. object based  programmingObject oriented vs. object based  programming
Object oriented vs. object based programmingMohammad Kamrul Hasan
 
Java OOP Concept
Java OOP ConceptJava OOP Concept
Java OOP ConceptNikitaGour5
 
L1-Introduction to OOPs concepts.pdf
L1-Introduction to OOPs concepts.pdfL1-Introduction to OOPs concepts.pdf
L1-Introduction to OOPs concepts.pdfBhanuJatinSingh
 

Semelhante a Chapter3 bag1 (20)

CS3391 -OOP -UNIT – I NOTES FINAL.pdf
CS3391 -OOP -UNIT – I  NOTES FINAL.pdfCS3391 -OOP -UNIT – I  NOTES FINAL.pdf
CS3391 -OOP -UNIT – I NOTES FINAL.pdf
 
OBJECT ORIENTED PROGRAMMING CONCEPTS IN C++.pptx
OBJECT ORIENTED PROGRAMMING CONCEPTS IN C++.pptxOBJECT ORIENTED PROGRAMMING CONCEPTS IN C++.pptx
OBJECT ORIENTED PROGRAMMING CONCEPTS IN C++.pptx
 
OOPS
OOPSOOPS
OOPS
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)
 
oop Lecture 7
oop Lecture 7oop Lecture 7
oop Lecture 7
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
CS3391 OOP UT-I T2 OBJECT ORIENTED PROGRAMMING PARADIGM.pptx
CS3391 OOP UT-I T2 OBJECT ORIENTED PROGRAMMING PARADIGM.pptxCS3391 OOP UT-I T2 OBJECT ORIENTED PROGRAMMING PARADIGM.pptx
CS3391 OOP UT-I T2 OBJECT ORIENTED PROGRAMMING PARADIGM.pptx
 
CS3391 OOP UT-I T3 FEATURES OF OBJECT ORIENTED PROGRAMMING
CS3391 OOP UT-I T3 FEATURES OF OBJECT ORIENTED PROGRAMMINGCS3391 OOP UT-I T3 FEATURES OF OBJECT ORIENTED PROGRAMMING
CS3391 OOP UT-I T3 FEATURES OF OBJECT ORIENTED PROGRAMMING
 
Object oriented progrmming
Object oriented progrmmingObject oriented progrmming
Object oriented progrmming
 
Lecture 2 cst 205-281 oop
Lecture 2   cst 205-281 oopLecture 2   cst 205-281 oop
Lecture 2 cst 205-281 oop
 
Bluej
BluejBluej
Bluej
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
Programming Laboratory Unit 1.pdf
Programming Laboratory Unit 1.pdfProgramming Laboratory Unit 1.pdf
Programming Laboratory Unit 1.pdf
 
Object Oriented Programming.pptx
 Object Oriented Programming.pptx Object Oriented Programming.pptx
Object Oriented Programming.pptx
 
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdfSulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
 
Basics of object oriented programming
Basics of object oriented programmingBasics of object oriented programming
Basics of object oriented programming
 
DISE - OOAD Using UML
DISE - OOAD Using UMLDISE - OOAD Using UML
DISE - OOAD Using UML
 
Object oriented vs. object based programming
Object oriented vs. object based  programmingObject oriented vs. object based  programming
Object oriented vs. object based programming
 
Java OOP Concept
Java OOP ConceptJava OOP Concept
Java OOP Concept
 
L1-Introduction to OOPs concepts.pdf
L1-Introduction to OOPs concepts.pdfL1-Introduction to OOPs concepts.pdf
L1-Introduction to OOPs concepts.pdf
 

Mais de teknik komputer ui (20)

Modul 1
Modul 1Modul 1
Modul 1
 
Modul 5
Modul 5Modul 5
Modul 5
 
Modul 4
Modul 4Modul 4
Modul 4
 
Modul 3
Modul 3Modul 3
Modul 3
 
Modul 1
Modul 1Modul 1
Modul 1
 
Modul 2
Modul 2Modul 2
Modul 2
 
The cisco networking academy net riders indonesia 2010 competition
The cisco networking academy net riders indonesia 2010 competitionThe cisco networking academy net riders indonesia 2010 competition
The cisco networking academy net riders indonesia 2010 competition
 
Rencana Proyek Divisi Komputer.doc
Rencana Proyek Divisi Komputer.docRencana Proyek Divisi Komputer.doc
Rencana Proyek Divisi Komputer.doc
 
Salinan Research Paper
Salinan Research PaperSalinan Research Paper
Salinan Research Paper
 
Chapter_1_Case_Study
Chapter_1_Case_StudyChapter_1_Case_Study
Chapter_1_Case_Study
 
Iins practice questions
Iins practice questionsIins practice questions
Iins practice questions
 
S1 intr ftui
S1 intr ftuiS1 intr ftui
S1 intr ftui
 
Exploration network chapter7
Exploration network chapter7Exploration network chapter7
Exploration network chapter7
 
Exploration network chapter6
Exploration network chapter6Exploration network chapter6
Exploration network chapter6
 
Exploration network chapter5
Exploration network chapter5Exploration network chapter5
Exploration network chapter5
 
Exploration network chapter4
Exploration network chapter4Exploration network chapter4
Exploration network chapter4
 
Exploration network chapter3
Exploration network chapter3Exploration network chapter3
Exploration network chapter3
 
Exploration network chapter2
Exploration network chapter2Exploration network chapter2
Exploration network chapter2
 
Exploration network chapter1
Exploration network chapter1Exploration network chapter1
Exploration network chapter1
 
Exploration network chapter11
Exploration network chapter11Exploration network chapter11
Exploration network chapter11
 

Chapter3 bag1

  • 1. Lecturer: Session-3 Kalamullah Ramli Electrical Engineering Dept. University of Indonesia Object Oriented Programming Principles
  • 2. Object-Oriented Programming: A New Programming Paradigm… What is Matlab's programming paradigm? Matlab is procedural: the focus is on the functions (procedures) What is the programming paradigm in OOP? As the name suggests, in OOP the focus is on OBJECTS This doesn't say much unless we understand what we mean with the term Object… So let's move on. OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 2
  • 3. Objects Combine Properties & Behavior [1/2] Remember following Structures: person.firstname = 'John'; person.lastname = 'Leonard'; person.address1 = '803 Shallowford Lane'; person.city = 'Peachtree City'; person.state = 'GA'; person.zip = '30269-4289'; A structure contains data in an organized fashion. OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 3
  • 4. Objects Combine Properties & Behavior [2/2] If we add functions or methods to a structure, it becomes an object: person.print_address(); person.set_lastName('Paredis'); OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 4
  • 5. More Examples of Objects [1/2] Car: Properties: color, speed, fuel consumption, HP… Behaviors: start, stop, turning, … Triangle: Properties: area, perimeter, linestyle, location,… Behaviors: translate, rotate, shrink, flip,… Date: Properties: year, month, day, … Behaviors: setDate, getMonth, isGreater, … OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 5
  • 6. More Examples of Objects [1/2] Properties: information about the object Behaviors: methods to set, get and process properties Combining properties and behaviors in objects is called Encapsulation OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 6
  • 7. Objects Combine Properties and Behavior: So What? Why should we care? [1/2] Black Box Philosophy: Objects perform computation Messages by making requests of each other through the passing of messages Code The only way to interact with an object is through its Data methods! http://java.sun.com/docs/books/tutorial/java/concepts/object.html OOP Lecture 2004 http://catalog.com/softinfo/objects.html Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 7
  • 8. Objects Combine Properties and Behavior: So What? Why should we care? [2/2] This is called Information Hiding (the data is hidden from the user) The collection of all methods is called the interface of the object http://java.sun.com/docs/books/tutorial/java/concepts/object.html OOP Lecture 2004 http://catalog.com/softinfo/objects.html Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 8
  • 9. Encapsulation and Data Hiding [1/2] Properties (Variables) Speed RPM Current Gear Methods (Functions) Braking Acceleration Turn Changing Gears OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 9
  • 10. Encapsulation and Data Hiding [2/2] These methods are independent of how the bicycle has been built (hides the implementation) You can control access to members of an object OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 10
  • 11. Working with Objects: Messages [1/2] Objects perform computation by making requests of each other through the passing of messages Parts of a message – The object to which the message is addressed The name of the method to perform Any parameters needed by the method OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 11
  • 12. Working with Objects: Messages [2/2] Different objects may respond differently to an identical message: bicycle.changeGears(lowerGear) car.changeGears(lowerGear) The same name and the same argument, but a different method = POLYMORPHISM A method is defined only in the scope of a particular type of object, called class Polymorphism is also called: function overloading OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 12
  • 13. Class and Object [1/2] Now that we know what an object is all about, let's look at how we can organize these objects Class = A blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind Objects are individual instances of a class OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 13
  • 14. Class and Object [2/2] House Plans: A House: the architectural drawings that The house built from the plans describe how a house is to be is an instance of the House Class. constructed The process of building the house is called Instantiation OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 14
  • 15. Organizing Objects: Inheritance [1/2] Children inherit Super class • properties (parent) • behaviors Sub class (child) OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 15
  • 16. Organizing Objects: Inheritance [2/2] Sub class (Child) • A class that is derived from a particular class, perhaps with one or more classes in between Super class (Parent) • A class from which a particular class is derived, perhaps with one or more classes in between Inheritance promotes Reuse of code Better Management of code OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 16
  • 17. Abstraction in OOP [1/2] Abstractions reveal causes and effects, expose patterns and frameworks and separate what's important from what's not Abstraction in programming helps you make your ideas concrete in your code without obscuring the architecture with details In procedural languages: structures and functions are abstractions OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 17
  • 18. Abstraction in OOP [2/2] OOP takes abstraction one step further through: encapsulation data hiding polymorphism Inheritance OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 18
  • 19. Object-Oriented Programming [1/2] A Quick Review: “OOP is more a way of thinking than just a programming technique” – “conceptual tool that you use in thinking how to solve a problem” Computer objects form the basis Objects treated as real life objects Identities Properties Behaviors Data and functionality encapsulated in an object Data hidden behind methods OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 19
  • 20. Object-Oriented Programming [2/2] Objects organized in class hierarchies: inheritance Objects interact through messages – methods Polymorphism: the same message has a different meaning for different objects OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 20
  • 21. Benefits of Object Oriented Programming Analysis and Design made easier Understanding of code made easier Code Reuse Ease of maintenance and enhancement Simplifies collaboration Fewer and shorter design iterations OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 21
  • 22. Examples of Programming Languages Procedural languages C FORTRAN BASIC Pascal Object Oriented languages C++ Smalltalk Java OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 22
  • 23. Assignment#2a: OOP vs Procedural Programming Object-Oriented Procedural Due date: Friday, February 27th, 2004 OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 23
  • 24. Assignment#2b: Object Oriented Philosophy “Simulate the functionality of your computer using the object oriented philosophy” Draw a diagram of the components present in the computer. What is the flow of information between these components? Leverage from previous lectures. Identify the classes and objects that you would need to simulate these components. How do these classes interact? Identify the variables and methods that you would assign to each class. Due Date: Friday, March 5th, 2004 OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 24
  • 25. References and Additional Reading “Object Oriented Programming, ” http://www.toodarkpark.net/computers/objc/oop.h tml “Core Java, ” Cay S. Horstmann and Gary Cornell, Sun Microsystems “ Thinking in C++, ” Bruce Eckel, http://www.mindview.net/Books/TICPP/ThinkingInC PP2e.html “ Introduction to Object Oriented Programming, ” Timothy Budd, ftp://ftp.cs.orst.edu/pub/budd/oopintro/3rdEdition /info.html OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 25
  • 26. Closure Learning Object oriented programming is more a philosophy than mere technique to develop programs… This philosophy provides modularity to programs Modularity provides openness to change… Enables developing complex systems Food for Thought How will object oriented philosophy help in the future of software development? How can the object oriented philosophy based on modularity be used in your field of specialization? What changes are required to adapt this philosophy to your field? OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 26
  • 27. The End QUESTIONS & COMMENTS ? OOP Lecture 2004 Dr. –Ing. Ir. Kalamullah Ramli, M.Eng Ing. Ramli, Slide - 27