SlideShare une entreprise Scribd logo
1  sur  59
Lecture slides by:
A new paradigm                        Farhan Amjad
of programming
 After   this lecture, you should be able to
    Difference of OO technique by other techniques
    Understand the meaning of object
    Know the difference between an object and a
     class
    Know the concepts of object orientation
    Understand how objects communicate
OOPS

It’s OOP not OOPS
   Detailed Course Outline is on the subject homepage
      http://groups.google.com/group/sp09_bcs2
Check your email often for announcements related to
                     the course
   Recommended Books:
       OOP using C++ 6th Edition, Prentice Hall
   Reference Books:
       OOP in C++ by Robert Lafore
       Thinking in C++, 2nd Edition, by Bruce Eckel
But not in Class. What
you have to do is just
inform me about your
situation and I will not
mark your absent.
Course Policy
 Applicablerules and submission deadlines will
 be indicated with the assignments

 No   make-ups
   10-15 minutes duration

   Will cover reading assignments and
    material covered in the class

   Unannounced

   No make-ups
    Supervised Lab Sessions and Tutorials will be
    organized as and when required.
I   will ask questions very often
    So be attentive
 Actually,  programming is not so
  easy, because a real good program is not
  easily programmed. It needs the
  programmers’ lots of wisdom, lots of
  knowledge about programming and lots of
  experience.
 It is like writing, to be a good writer needs
  lots of experience and lots of knowledge
  about the world.
 Learning and practice are necessary.
 Usually,people start learning
 programming by writing small
 and simple programs
 consisting only of one main      Main Program
 program. Here ``main
 program'' stands for a              Data
 sequence of commands or
 statements which modify data
 which is global throughout the
 whole program.
 This programming technique can only be used in
  a very small program.
 For example, if the same statement sequence is
  needed at different locations within the
  program, the sequence must be copied. If an
  error needed to be modified, every copy needs
  to be modified.
 This has lead to the idea to extract these
  sequences(procedure), name them and offering
  a technique to call and return from these
  procedures.
 With  procedural programming,     Main
                                             Procedure
  you are able to combine          Program
  sequences of calling
  statements into one single
  place.
 A procedure call is used to
  invoke the procedure. After
  the sequence is processed,
  flow of control proceeds right
  after the position where the
  call was made .
 Programs  can now be written more
  structured and error free.
 For example, if a procedure is
  correct, every time it is used it produces
  correct results.
 Consequently, in cases of errors you can
  narrow your search to those places which
  are not proven to be correct.
 Now  a program can be viewed as a sequence of
  procedure calls.
 The main program is responsible to pass data to
  the individual calls, the data is processed by the
  procedures and the resulting data is presented.
 Thus, the flow of data can be illustrated as a
  hierarchical graph, a tree.
Main Program
                Data


Procedure1     Procedure2   Procedure3
 Modular  programming is subdividing your
  program into separate subprograms such as
  functions and subroutines.
 With modular programming, procedures of a
  common functionality are grouped together
  into separate modules.
 A program therefore no longer consists of
  only one single part. It is now divided into
  several smaller parts which interact through
  procedure calls and which form the whole
  program.
Main Program(Also a module)

                                     Data




            Module1                              Module2
             +                                   +
     Data         Data11
                   Data                     Data      Data2




         Procedure1                   Procedure2         Procedure3




The main program coordinates calls to procedures in separate modules and
hands over appropriate data as parameters.
 Each  module can have its own data. This allows
  each module to manage an internal state which
  is modified by calls to procedures of this
  module.
 Each module has its own special functionalities
  that supports the implementation of the whole
  program.
 Also structured programming
 A subset of procedural programming that
  enforces a logical structure on the program
  being written to make it more efficient and
  easier to understand and modify.
 Certain languages such as Ada, Pascal, and
  dBASE are designed with features that
  encourage or enforce a logical program
Global Data        Global Data         Global Data




  Function    Function      Function      Function
 When  the program grows larger and more
  complex even the structural programming
  shows the strain.
 You may have heard horror stories of project’s
  complexity, schedule slipping etc.
 In procedural programming data is given
  second class status.
Inventory system-> new programmer->writes the function
  It is same like you are sitting in your lobby and
  left there your personal documents.
 It   is a kind of thinking methodology
      Everything in the world is an object;
      Any system is composed of objects (certainly a system is
       also an object);
      The evolution and development of a system is caused by
       the interactions among the objects inside or outside the
       system
   Build programming using software objects.
   Means that we organize software as a
    collection of discrete (different) objects
    that incorporate both data structure and
    behavior.
   In OOP, the software objects correspond
    closely to real objects involve in the
    application area.
A  flower, a tree, an animal
 A student, a professor
 A desk, a chair, a classroom, a building
 A university, a city, a country
 The world, the universe
 A subject such as CS, IS, Math, History, …
A  law system
 A cultural system
 An educational system
 An economic system
 An Information system
 A computer system
 University   is developed by the interactions
 among:
    students
    professors
    staffs
    officers of Bio-science
    officers of CIIT
    … ...
   ADTs allows the creation of instances with well-defined
    properties and behavior.
    In object-orientation, ADTs are referred to as classes.
   Therefore, a class defines properties of objects which
    are the instances in an object-oriented environment.
   Object-oriented programming is ``programming with
    ADTs'': combining functionality of different ADTs to solve
    a problem.
   Therefore instances (objects) of ADTs (classes) are
    dynamically created, destroyed and used.
Object1

                          Data1+Procedures1




      Object2

Data2 + Procedures2 1
               Data
                                                    Object3

                                              Data3 + Procedures3



                        Object4

                Data4 + Procedures4
 An object-based programming language is one
  which easily supports object-orientation.
 Smalltalk:1972-1980, Alan Kay
 C++:1986, Bjarne Stroustrup
 Java:1992 (Smalltalk + C++), James Gosling
 C#:
    Developed at Microsoft by Anders Hejlsberg et al, 2000
    Event driven, object oriented, visual programming
     language (C++ and Java)
◆   Complexity & Haste:
   Skilled programmer: 10-15 lines of code a day
   Price ~ $18/line
   Can you pay this? If not, what will you do?
   Hire non professionals?
◆   OOP fights Complexity:
   A more realistic model of the world
   Collection of interacting objects instead of a
    collection of functions
   Reuse of ready made components
 Reduce    development cost:
    one component instead of many
 Promote    reliability:
    exercise component from many different aspects
 noneed to remember to correct the same
 error twice
    INFO TECH RESEARCH FUNDING
     The Clinton Administration has targeted 5
     technology areas for support from the National
     Institute of Standards & Technology, and two
     focus directly on information technology: a
     nationwide health care information infrastructure
     and an effort to develop reusable software
     components for large software systems.
     [Wall Street Journal, 26 April ‘94, Page B6]



Reuse is tightly coupled with abstraction:
● Identify similarity between elements.
● Create a component that represents the similar parts.
● Rewrite elements to use the common part.
 Adding new features responding to changing
  operation environment can be a matter of
  introducing a few new objects.
 Easy to make minor changes in the data
  representation/ the procedures used in an OO
  program. Changes within an object do not affect
  any other parts of the program.
   Flexibility
    Very flexible in accommodating different
    situations because the interaction patterns
    among the object can be changed without
    modifying the object.
   Maintainability
    Objects can be maintained separately.
    Reusability
   Objects can be reused in the different
    programs.
 Data is more important then
  functions, methods, procedures etc but in
  procedural languages data is given the
  second class status. OOP also provides the
  mechanism to hide the data.
 Example:
    Importance of data in inventory system, banking
     system etc.
    You hire a new programmer and he accidently
     changes the corrupts the data. Same like
     someone changes your personal data.
 Reduces  complexity much like the detailed
  workings of an automobile are hidden from
  the average driver.
 Principle of least privilege (need-to-know)
 More Secure. Less likely that someone will
  alter or misuse something.
 Easier to change the implementation without
  affecting other modules that use it.
Classes
Objects
Data encapsulation
Inheritance
Polymorphism
   Class
     A generic definition for a set of similar
      objects.
     Provides the specifications for the
      objects’ behaviors and attributes.
     An abstraction of a real world entity.
The key concepts are:
 Object
   Directly relate to the real world entities.
   Can be a person, thing or concept.
   Like a “black box”, therefore all the
    implementation is hidden.
   Has a
    State (attribute)
    Behavior (operation)

    Identity (unique name)
Object vs Class
 object is created from a class.
 object is considered as an instance of a class.
 class is considered as a template from which
  objects are instantiated
 can create an object or many objects from a
  class.
Object vs Class
Diagram 1: Class Car   Diagram 2: MyCar as an Object

        Car


    Door
    Seat
    Type
    Model



    Drive
    Stop
    Lock
    Unlock
Messages
 Requests for the receiver objects to carry
  out the indicated method or behavior and
  return the result of that action to the
  sender objects
   Encapsulation
     Process of hiding the implementation
      details of an object.
     Access to manipulate the object data is
      through its interface (operations/
      functions).
     Protects an object’s internal state from
      being corrupted by other programs.
   Encapsulation (cont)
     Program maintenance is easier and less
      expensive because changes in the
      object data or implementation is only
      modified in one place
     Allows objects to be viewed as black
      boxes.
   Inheritance
     Code reuse mechanism to build new
      objects out of old ones.
     Defines a relationship among classes
      where one class shares the structure
      and/or behavior on one or more
      classes.
     Provides a more flexible and adaptable
      system and enables polymorphism.
   Polymorphism
     Means having many forms.
     Provides the ability to use a single
      message to invoke many different kinds
      of behavior.
     Same name with different meaning.
 Protected    levels in a class:
     Public: Can be accessed both within and external
      to the object.
     Private: Can only be used by the object itself.
 The  public section of a class is usually called
  the interface. It is what the programmers
  sees.
 Normally, All data is private and only the
  bare essential functions are made public.
 What   is Object Oriented Programming?
 Object-oriented programming is a method
  of implementation in which programs are
  organized as cooperative collections of
  objects, each of which represents an
  instance of some class, and whose classes
  are all members of one or more hierarchy
  of classes united via inheritance
  relationships
 OOP  by Robert Lafore
 OOP by Deitel and Deitel
 Haibin Zhu, Ph. D. Associate Professor of CS,
  Nipissing University
 Complete Reference

Contenu connexe

Tendances

1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)Jay Patel
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingAmit Soni (CTFL)
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Michelle Anne Meralpis
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingIqra khalil
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingMoutaz Haddara
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++rprajat007
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops conceptsNilesh Dalvi
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS ConceptBoopathi K
 
class and objects
class and objectsclass and objects
class and objectsPayel Guria
 
Object Oriented Programming ppt presentation
Object Oriented Programming ppt presentationObject Oriented Programming ppt presentation
Object Oriented Programming ppt presentationAyanaRukasar
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vishal Patil
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in JavaSpotle.ai
 
Pure virtual function and abstract class
Pure virtual function and abstract classPure virtual function and abstract class
Pure virtual function and abstract classAmit Trivedi
 
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
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT03062679929
 
Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesFellowBuddy.com
 

Tendances (20)

1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
class and objects
class and objectsclass and objects
class and objects
 
Object Oriented Programming ppt presentation
Object Oriented Programming ppt presentationObject Oriented Programming ppt presentation
Object Oriented Programming ppt presentation
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Pure virtual function and abstract class
Pure virtual function and abstract classPure virtual function and abstract class
Pure virtual function and abstract class
 
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
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture Notes
 

En vedette

SSRP Self Learning Guide Maths Class 10 - In Hindi
SSRP Self Learning Guide Maths Class 10 - In HindiSSRP Self Learning Guide Maths Class 10 - In Hindi
SSRP Self Learning Guide Maths Class 10 - In Hindikusumafoundation
 
Introduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented LanguagesIntroduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented LanguagesGuido Wachsmuth
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingHaris Bin Zahid
 
Cbse class 10 hindi course b model answers by candidates 2015
Cbse class 10 hindi course b model answers by candidates 2015Cbse class 10 hindi course b model answers by candidates 2015
Cbse class 10 hindi course b model answers by candidates 2015Saurabh Singh Negi
 
High Level Languages (Imperative, Object Orientated, Declarative)
High Level Languages (Imperative, Object Orientated, Declarative)High Level Languages (Imperative, Object Orientated, Declarative)
High Level Languages (Imperative, Object Orientated, Declarative)Project Student
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
हिन्दी व्याकरण
हिन्दी व्याकरणहिन्दी व्याकरण
हिन्दी व्याकरणChintan Patel
 
Chapter3: fundamental programming
Chapter3: fundamental programmingChapter3: fundamental programming
Chapter3: fundamental programmingNgeam Soly
 
OOPs concept and implementation
OOPs concept and implementationOOPs concept and implementation
OOPs concept and implementationSandeep Kumar P K
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPTAjay Chimmani
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic Manzoor ALam
 

En vedette (20)

Unit i
Unit iUnit i
Unit i
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
Labsheet2
Labsheet2Labsheet2
Labsheet2
 
SSRP Self Learning Guide Maths Class 10 - In Hindi
SSRP Self Learning Guide Maths Class 10 - In HindiSSRP Self Learning Guide Maths Class 10 - In Hindi
SSRP Self Learning Guide Maths Class 10 - In Hindi
 
Oops
OopsOops
Oops
 
Oops Concepts
Oops ConceptsOops Concepts
Oops Concepts
 
Introduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented LanguagesIntroduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented Languages
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Cbse class 10 hindi course b model answers by candidates 2015
Cbse class 10 hindi course b model answers by candidates 2015Cbse class 10 hindi course b model answers by candidates 2015
Cbse class 10 hindi course b model answers by candidates 2015
 
High Level Languages (Imperative, Object Orientated, Declarative)
High Level Languages (Imperative, Object Orientated, Declarative)High Level Languages (Imperative, Object Orientated, Declarative)
High Level Languages (Imperative, Object Orientated, Declarative)
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
Labsheet1stud
Labsheet1studLabsheet1stud
Labsheet1stud
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
हिन्दी व्याकरण
हिन्दी व्याकरणहिन्दी व्याकरण
हिन्दी व्याकरण
 
Chapter3: fundamental programming
Chapter3: fundamental programmingChapter3: fundamental programming
Chapter3: fundamental programming
 
OOPs concept and implementation
OOPs concept and implementationOOPs concept and implementation
OOPs concept and implementation
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
 
कारक
कारककारक
कारक
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 

Similaire à Introduction to object oriented language

Software_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptxSoftware_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptxArifaMehreen1
 
Object Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptxObject Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptxparveen837153
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++ shammi mehra
 
PCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxPCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxprakashvs7
 
Object Oriented programming - Introduction
Object Oriented programming - IntroductionObject Oriented programming - Introduction
Object Oriented programming - IntroductionMadishetty Prathibha
 
Unit1 jaava
Unit1 jaavaUnit1 jaava
Unit1 jaavamrecedu
 
A Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdfA Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdfAnn Wera
 
PCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxPCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxvishnupriyapm4
 
DOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cDOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cfloraaluoch3
 
POP vs OOP Introduction
POP vs OOP IntroductionPOP vs OOP Introduction
POP vs OOP IntroductionHashni T
 
PCCF UNIT 2.pptx
PCCF UNIT 2.pptxPCCF UNIT 2.pptx
PCCF UNIT 2.pptxDivyaKS12
 

Similaire à Introduction to object oriented language (20)

OOP ppt.pdf
OOP ppt.pdfOOP ppt.pdf
OOP ppt.pdf
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
 
Oop basic overview
Oop basic overviewOop basic overview
Oop basic overview
 
Software_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptxSoftware_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptx
 
Object Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptxObject Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptx
 
Chapter1 introduction
Chapter1 introductionChapter1 introduction
Chapter1 introduction
 
C++ notes.pdf
C++ notes.pdfC++ notes.pdf
C++ notes.pdf
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++
 
PCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxPCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docx
 
Object Oriented programming - Introduction
Object Oriented programming - IntroductionObject Oriented programming - Introduction
Object Oriented programming - Introduction
 
OOP.pptx
OOP.pptxOOP.pptx
OOP.pptx
 
chapter-6-oops.pdf
chapter-6-oops.pdfchapter-6-oops.pdf
chapter-6-oops.pdf
 
Unit1 jaava
Unit1 jaavaUnit1 jaava
Unit1 jaava
 
A Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdfA Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdf
 
PCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxPCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptx
 
DOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cDOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in c
 
POP vs OOP Introduction
POP vs OOP IntroductionPOP vs OOP Introduction
POP vs OOP Introduction
 
PCCF UNIT 2.pptx
PCCF UNIT 2.pptxPCCF UNIT 2.pptx
PCCF UNIT 2.pptx
 
Birasa 1
Birasa 1Birasa 1
Birasa 1
 
JAVA PROGRAMMING
JAVA PROGRAMMING JAVA PROGRAMMING
JAVA PROGRAMMING
 

Plus de farhan amjad

Views and security
Views and securityViews and security
Views and securityfarhan amjad
 
Views and security
Views and securityViews and security
Views and securityfarhan amjad
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templatesfarhan amjad
 
Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)farhan amjad
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingfarhan amjad
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methodsfarhan amjad
 

Plus de farhan amjad (6)

Views and security
Views and securityViews and security
Views and security
 
Views and security
Views and securityViews and security
Views and security
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templates
 
Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
 

Dernier

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 

Dernier (20)

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 

Introduction to object oriented language

  • 1. Lecture slides by: A new paradigm Farhan Amjad of programming
  • 2.  After this lecture, you should be able to  Difference of OO technique by other techniques  Understand the meaning of object  Know the difference between an object and a class  Know the concepts of object orientation  Understand how objects communicate
  • 4. Detailed Course Outline is on the subject homepage http://groups.google.com/group/sp09_bcs2 Check your email often for announcements related to the course
  • 5. Recommended Books:  OOP using C++ 6th Edition, Prentice Hall  Reference Books:  OOP in C++ by Robert Lafore  Thinking in C++, 2nd Edition, by Bruce Eckel
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. But not in Class. What you have to do is just inform me about your situation and I will not mark your absent.
  • 13.
  • 14.  Applicablerules and submission deadlines will be indicated with the assignments  No make-ups
  • 15. 10-15 minutes duration  Will cover reading assignments and material covered in the class  Unannounced  No make-ups
  • 16. Supervised Lab Sessions and Tutorials will be organized as and when required.
  • 17. I will ask questions very often  So be attentive
  • 18.  Actually, programming is not so easy, because a real good program is not easily programmed. It needs the programmers’ lots of wisdom, lots of knowledge about programming and lots of experience.  It is like writing, to be a good writer needs lots of experience and lots of knowledge about the world.  Learning and practice are necessary.
  • 19.  Usually,people start learning programming by writing small and simple programs consisting only of one main Main Program program. Here ``main program'' stands for a Data sequence of commands or statements which modify data which is global throughout the whole program.
  • 20.  This programming technique can only be used in a very small program.  For example, if the same statement sequence is needed at different locations within the program, the sequence must be copied. If an error needed to be modified, every copy needs to be modified.  This has lead to the idea to extract these sequences(procedure), name them and offering a technique to call and return from these procedures.
  • 21.  With procedural programming, Main Procedure you are able to combine Program sequences of calling statements into one single place.  A procedure call is used to invoke the procedure. After the sequence is processed, flow of control proceeds right after the position where the call was made .
  • 22.  Programs can now be written more structured and error free.  For example, if a procedure is correct, every time it is used it produces correct results.  Consequently, in cases of errors you can narrow your search to those places which are not proven to be correct.
  • 23.
  • 24.  Now a program can be viewed as a sequence of procedure calls.  The main program is responsible to pass data to the individual calls, the data is processed by the procedures and the resulting data is presented.  Thus, the flow of data can be illustrated as a hierarchical graph, a tree.
  • 25. Main Program Data Procedure1 Procedure2 Procedure3
  • 26.  Modular programming is subdividing your program into separate subprograms such as functions and subroutines.  With modular programming, procedures of a common functionality are grouped together into separate modules.  A program therefore no longer consists of only one single part. It is now divided into several smaller parts which interact through procedure calls and which form the whole program.
  • 27. Main Program(Also a module) Data Module1 Module2 + + Data Data11 Data Data Data2 Procedure1 Procedure2 Procedure3 The main program coordinates calls to procedures in separate modules and hands over appropriate data as parameters.
  • 28.  Each module can have its own data. This allows each module to manage an internal state which is modified by calls to procedures of this module.  Each module has its own special functionalities that supports the implementation of the whole program.
  • 29.  Also structured programming  A subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify.  Certain languages such as Ada, Pascal, and dBASE are designed with features that encourage or enforce a logical program
  • 30. Global Data Global Data Global Data Function Function Function Function
  • 31.  When the program grows larger and more complex even the structural programming shows the strain.  You may have heard horror stories of project’s complexity, schedule slipping etc.  In procedural programming data is given second class status. Inventory system-> new programmer->writes the function It is same like you are sitting in your lobby and left there your personal documents.
  • 32.  It is a kind of thinking methodology  Everything in the world is an object;  Any system is composed of objects (certainly a system is also an object);  The evolution and development of a system is caused by the interactions among the objects inside or outside the system
  • 33. Build programming using software objects.  Means that we organize software as a collection of discrete (different) objects that incorporate both data structure and behavior.  In OOP, the software objects correspond closely to real objects involve in the application area.
  • 34. A flower, a tree, an animal  A student, a professor  A desk, a chair, a classroom, a building  A university, a city, a country  The world, the universe  A subject such as CS, IS, Math, History, …
  • 35. A law system  A cultural system  An educational system  An economic system  An Information system  A computer system
  • 36.  University is developed by the interactions among:  students  professors  staffs  officers of Bio-science  officers of CIIT  … ...
  • 37. ADTs allows the creation of instances with well-defined properties and behavior.  In object-orientation, ADTs are referred to as classes.  Therefore, a class defines properties of objects which are the instances in an object-oriented environment.  Object-oriented programming is ``programming with ADTs'': combining functionality of different ADTs to solve a problem.  Therefore instances (objects) of ADTs (classes) are dynamically created, destroyed and used.
  • 38. Object1 Data1+Procedures1 Object2 Data2 + Procedures2 1 Data Object3 Data3 + Procedures3 Object4 Data4 + Procedures4
  • 39.  An object-based programming language is one which easily supports object-orientation.  Smalltalk:1972-1980, Alan Kay  C++:1986, Bjarne Stroustrup  Java:1992 (Smalltalk + C++), James Gosling  C#:  Developed at Microsoft by Anders Hejlsberg et al, 2000  Event driven, object oriented, visual programming language (C++ and Java)
  • 40. ◆ Complexity & Haste:  Skilled programmer: 10-15 lines of code a day  Price ~ $18/line  Can you pay this? If not, what will you do?  Hire non professionals? ◆ OOP fights Complexity:  A more realistic model of the world  Collection of interacting objects instead of a collection of functions  Reuse of ready made components
  • 41.  Reduce development cost:  one component instead of many  Promote reliability:  exercise component from many different aspects  noneed to remember to correct the same error twice
  • 42. INFO TECH RESEARCH FUNDING The Clinton Administration has targeted 5 technology areas for support from the National Institute of Standards & Technology, and two focus directly on information technology: a nationwide health care information infrastructure and an effort to develop reusable software components for large software systems. [Wall Street Journal, 26 April ‘94, Page B6] Reuse is tightly coupled with abstraction: ● Identify similarity between elements. ● Create a component that represents the similar parts. ● Rewrite elements to use the common part.
  • 43.  Adding new features responding to changing operation environment can be a matter of introducing a few new objects.  Easy to make minor changes in the data representation/ the procedures used in an OO program. Changes within an object do not affect any other parts of the program.
  • 44. Flexibility Very flexible in accommodating different situations because the interaction patterns among the object can be changed without modifying the object.  Maintainability Objects can be maintained separately. Reusability  Objects can be reused in the different programs.
  • 45.  Data is more important then functions, methods, procedures etc but in procedural languages data is given the second class status. OOP also provides the mechanism to hide the data.  Example:  Importance of data in inventory system, banking system etc.  You hire a new programmer and he accidently changes the corrupts the data. Same like someone changes your personal data.
  • 46.  Reduces complexity much like the detailed workings of an automobile are hidden from the average driver.  Principle of least privilege (need-to-know)  More Secure. Less likely that someone will alter or misuse something.  Easier to change the implementation without affecting other modules that use it.
  • 48. Class  A generic definition for a set of similar objects.  Provides the specifications for the objects’ behaviors and attributes.  An abstraction of a real world entity.
  • 49. The key concepts are:  Object  Directly relate to the real world entities.  Can be a person, thing or concept.  Like a “black box”, therefore all the implementation is hidden.  Has a  State (attribute)  Behavior (operation)  Identity (unique name)
  • 50. Object vs Class  object is created from a class.  object is considered as an instance of a class.  class is considered as a template from which objects are instantiated  can create an object or many objects from a class.
  • 51. Object vs Class Diagram 1: Class Car Diagram 2: MyCar as an Object Car Door Seat Type Model Drive Stop Lock Unlock
  • 52. Messages  Requests for the receiver objects to carry out the indicated method or behavior and return the result of that action to the sender objects
  • 53. Encapsulation  Process of hiding the implementation details of an object.  Access to manipulate the object data is through its interface (operations/ functions).  Protects an object’s internal state from being corrupted by other programs.
  • 54. Encapsulation (cont)  Program maintenance is easier and less expensive because changes in the object data or implementation is only modified in one place  Allows objects to be viewed as black boxes.
  • 55. Inheritance  Code reuse mechanism to build new objects out of old ones.  Defines a relationship among classes where one class shares the structure and/or behavior on one or more classes.  Provides a more flexible and adaptable system and enables polymorphism.
  • 56. Polymorphism  Means having many forms.  Provides the ability to use a single message to invoke many different kinds of behavior.  Same name with different meaning.
  • 57.  Protected levels in a class:  Public: Can be accessed both within and external to the object.  Private: Can only be used by the object itself.  The public section of a class is usually called the interface. It is what the programmers sees.  Normally, All data is private and only the bare essential functions are made public.
  • 58.  What is Object Oriented Programming?  Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of one or more hierarchy of classes united via inheritance relationships
  • 59.  OOP by Robert Lafore  OOP by Deitel and Deitel  Haibin Zhu, Ph. D. Associate Professor of CS, Nipissing University  Complete Reference