Part 1 Introduction Object | Class Encapsulation Abstraction Messaging Polymorphism Presented by Nuzhat Ibrahim Memon
• In today era of internet, website and web based operations, rapid application development (RAD) and reusability of source code is very important. • Object oriented techniques as methodology or as paradigm is playing significant role in analysis, design and implementation of software system. • Software developed using object-oriented are proclaimed to be more reliable, easier to maintain, reuse and enhance. • Object-oriented programming concepts started originating in the 1960s. • Since mid 1980s, it has become the main programming paradigm used in the creation of new software. • Some of the popular programming languages that support object-oriented programming are C++, Java, C#, VB .net , ASP .net and PHP. s NUZHAT IBRAHIM MEMON 2
Presented by Nuzhat Ibrahim Memon 3 Boil(water) Boil(milk) Add(sugar) Add(tea-powder) Stir() Serve() the focus is on writing functions or procedures which operate on data liquid-type powder-type Boil (liquid-type) Add(powder-type) Stir() Serve() Function/Methods Data/variables Function/Procedure/Methods The way of programming can be divided into two categories namely the focus is on object which contains both data and functionality together. • The power of object-oriented programming language enables the programmer to create modular, reusable and extendable code. • Object-oriented programming uses as its fundamental building block. Similar objects are classified using a concept of class that support object-oriented.
• in procedure oriented programming , for library application software, we will think of all processes of library application and focus on the modules like student registration, book issue, book return, fine calculation • For library application in object oriented programming, our focus is on the object involved in the application. Here we think of object like student, book and librarian. We also need to think of association between such objects. For eg, student returns book. Presented by Nuzhat Ibrahim Memon 4 Library Application (POP) Students registration() Book issue() Book return() Fine calculation() Library Application (OOP) Students book Librarian Students registration() Book issue() Book return() Fine calculation()
Abstraction Encapsulation Polymorphism Inheritance Presented by Nuzhat Ibrahim Memon 5 A computer language is object-oriented if they support four specific object properties 4 Pillars of OOPs (A PIE)
• In the real world, objects are the entities of which the world is comprised. • Some objects can be concrete things like person, car or a coffee cup. While other objects may be abstract that do not represent things which can be touched or seen; for example, concept like date and time. Presented by Nuzhat Ibrahim Memon 6 Real world entities Instance of class
Attributes / Properties / Data Fields • All objects have unique identity and are distinguishable from each other. In object-oriented terminology, such characteristics are known as properties or attributes. • In object oriented programming, attributes that describe the object are also referred to as data fields. • To uniquely identify the object, the value of these attributes are used. These values are called State. • State is used to distinguish objects from each other. Behaviour • Additionally the behaviour associated with objects. The behaviour is also known as method. Members or Features • The data attributes and behavioral methods associated with an object are collectively referred to as its members or features. Presented by Nuzhat Ibrahim Memon 7 Name: Bob City: Pune Gender: Male Birthdate: 1st March Profession: Doctor Name: Lily City: Delhi Gender: Female Birthdate: 2nd May Profession:Teacher Name: xyz Color: Blue Model: xyz 2020 Manfacture: Honda Name: abc Color: Pink Model: abc 2021 Manufacture: BMW
Presented by Nuzhat Ibrahim Memon 8 • Class can be considered as a blueprint for various objects. • A class is a template for multiple objects with similar features. • It describes a group of objects with similar attributes and common behavior. Similar objects are classified using a concept of class. • Objects in the same class share a common semantic purpose. • Thus, the class is a general concept used to embody all the common features of a particular set of objects. ‘Car’
Presented by Nuzhat Ibrahim Memon 9 • For example, we have a class named ‘Person’ describing common attributes and behaviors of all persons. • In ’Person’ class , individual persons are considered as objects and are identified by the state; that is the value of their attributes Objects Class Few More Examples: Class: Human Object: Man, Woman Class: Animal Object: Cat, Dog, Rabbit Class: Fruit Object: Apple, Mango, Kiwi
• For any computer program, two core elements are data and function. • Structured/ procedural programming views these two core element as two separate entities; whereas object-oriented programming views them as single entity. • In procedural programming, data can be altered by any component of the program. It is not protected from modification. • In Object Oriented Programming, this problem can be solved using encapsulation. Presented by Nuzhat Ibrahim Memon 10 Data Data Data Procedure Programming Object 2 Object 1 Object 3 Data Data Data Object Oriented Programming
• Data and method that manipulate data are guarded against modification or misuse by other components of the program. • This mechanism of providing protection to data and methods of a program is called encapsulation. • This is possible by wrapping data and methods into a single unit known as class and declaring them as private. • Private members of the class are not available directly to outside world. If necessary , the data is made available via public methods. • Thus, encapsulation provides data hiding capabilities. • Encapsulation keeps the data safe from unintended actions and inadvertent access by outside objects. Presented by Nuzhat Ibrahim Memon 11 Class Data / Variable Function / Methods/ Behavior
• Data abstraction is a process of representing the essential features of the objects without including implementation detail. • Abstraction is a concept that hides complexity; it says what it does, but not how it is done. • Data abstraction is a technique that relies on the separation of interface and implementation. • Data abstraction provides the skeleton or templates for our use. • The system hides certain details of how data is stored, created and maintained. • Examples of data abstraction • Abstract Data Types(ADT) or Structures (struct) in C/C++ • classes in C++/Java • In ADT, we simply define a data type and set of operation on it. We do not show the implementation of operations. Presented by Nuzhat Ibrahim Memon 12
• Encapsulate protects data by making them inaccessible from outside. • Abstraction enables to represent data in which the implementation details are hidden (abstracted). Presented by Nuzhat Ibrahim Memon 13
• Different classes may have same methods with same name. • Date class->display() , display the date object in specific format • Time class->display(), to display time in specific format • person class -> display() to display the details of person • In object-oriented termixnology, a call to a method is referred to as a message. • When method ‘display’ is invoked in the program, how to know which method is to be executed? • This is determined using the object that invokes the method. • Due to encapsulation, all method calls are handled by objects that recognize the method • For eg. If ‘display’ is called by an object of ‘person’ class, it executes the display method defined in ‘person’ class. Presented by Nuzhat Ibrahim Memon 14 class date class time class person void display(){ System.out.println (“Display the date object in specific format”); } void display(){ System.out.println (“Display the time in specific format”); } void display(){ System.out.println (“Display the details of person”); } date d_obj = new date(); time t_obj = new time(); person p_obj = new person(); d_obj.display(); t_obj,display(); p_obj.display();
Presented by Nuzhat Ibrahim Memon 15 • Polymorphism means ‘many forms’. • The polymorphism is achieved using two type of overloading: function overloading and operator overloading. • The capability of using same names to mean different things in different contexts is called overloading. Operator Overloading Function Overloading Polymorphism
Presented by Nuzhat Ibrahim Memon 16 • Function or method overloading • It is possible to define more than one function with the same name in object-oriented programming. • The methods differs in signatures( number and type of parameters) • Object- oriented programming allows defining more than one method having same name but different signatures in a single class. This feature is known as function or method overloading. • Operator overloading • Object oriented programming also allows writing expression using operators on objects. • Date d1 – date d2 and n1- n2; operator ‘-’ is performing in a different way. • The same operation is given different meanings upon the data type of operands used. This type of polymorphism is achieved through operator overloading. Operator ‘+’ 2 + 2 = 4 ‘in’ + ‘dia’ = ‘India’ Operator ‘-’ n1 - n2 date d1 – date d2 Area (l,w) Area (pi,r,r) Shape Area ( *b*h) Max (int, int){ return int; } Max (array, size){ return int; }
Nuzhat Memon website: nuzhatmemon.com Email: nuzhat.memon@gmail.com

Std 12 computer chapter 6 object oriented concepts (part 1)

  • 1.
    Part 1 Introduction Object |Class Encapsulation Abstraction Messaging Polymorphism Presented by Nuzhat Ibrahim Memon
  • 2.
    • In todayera of internet, website and web based operations, rapid application development (RAD) and reusability of source code is very important. • Object oriented techniques as methodology or as paradigm is playing significant role in analysis, design and implementation of software system. • Software developed using object-oriented are proclaimed to be more reliable, easier to maintain, reuse and enhance. • Object-oriented programming concepts started originating in the 1960s. • Since mid 1980s, it has become the main programming paradigm used in the creation of new software. • Some of the popular programming languages that support object-oriented programming are C++, Java, C#, VB .net , ASP .net and PHP. s NUZHAT IBRAHIM MEMON 2
  • 3.
    Presented by NuzhatIbrahim Memon 3 Boil(water) Boil(milk) Add(sugar) Add(tea-powder) Stir() Serve() the focus is on writing functions or procedures which operate on data liquid-type powder-type Boil (liquid-type) Add(powder-type) Stir() Serve() Function/Methods Data/variables Function/Procedure/Methods The way of programming can be divided into two categories namely the focus is on object which contains both data and functionality together. • The power of object-oriented programming language enables the programmer to create modular, reusable and extendable code. • Object-oriented programming uses as its fundamental building block. Similar objects are classified using a concept of class that support object-oriented.
  • 4.
    • in procedureoriented programming , for library application software, we will think of all processes of library application and focus on the modules like student registration, book issue, book return, fine calculation • For library application in object oriented programming, our focus is on the object involved in the application. Here we think of object like student, book and librarian. We also need to think of association between such objects. For eg, student returns book. Presented by Nuzhat Ibrahim Memon 4 Library Application (POP) Students registration() Book issue() Book return() Fine calculation() Library Application (OOP) Students book Librarian Students registration() Book issue() Book return() Fine calculation()
  • 5.
    Abstraction Encapsulation Polymorphism Inheritance Presented by NuzhatIbrahim Memon 5 A computer language is object-oriented if they support four specific object properties 4 Pillars of OOPs (A PIE)
  • 6.
    • In thereal world, objects are the entities of which the world is comprised. • Some objects can be concrete things like person, car or a coffee cup. While other objects may be abstract that do not represent things which can be touched or seen; for example, concept like date and time. Presented by Nuzhat Ibrahim Memon 6 Real world entities Instance of class
  • 7.
    Attributes / Properties/ Data Fields • All objects have unique identity and are distinguishable from each other. In object-oriented terminology, such characteristics are known as properties or attributes. • In object oriented programming, attributes that describe the object are also referred to as data fields. • To uniquely identify the object, the value of these attributes are used. These values are called State. • State is used to distinguish objects from each other. Behaviour • Additionally the behaviour associated with objects. The behaviour is also known as method. Members or Features • The data attributes and behavioral methods associated with an object are collectively referred to as its members or features. Presented by Nuzhat Ibrahim Memon 7 Name: Bob City: Pune Gender: Male Birthdate: 1st March Profession: Doctor Name: Lily City: Delhi Gender: Female Birthdate: 2nd May Profession:Teacher Name: xyz Color: Blue Model: xyz 2020 Manfacture: Honda Name: abc Color: Pink Model: abc 2021 Manufacture: BMW
  • 8.
    Presented by NuzhatIbrahim Memon 8 • Class can be considered as a blueprint for various objects. • A class is a template for multiple objects with similar features. • It describes a group of objects with similar attributes and common behavior. Similar objects are classified using a concept of class. • Objects in the same class share a common semantic purpose. • Thus, the class is a general concept used to embody all the common features of a particular set of objects. ‘Car’
  • 9.
    Presented by NuzhatIbrahim Memon 9 • For example, we have a class named ‘Person’ describing common attributes and behaviors of all persons. • In ’Person’ class , individual persons are considered as objects and are identified by the state; that is the value of their attributes Objects Class Few More Examples: Class: Human Object: Man, Woman Class: Animal Object: Cat, Dog, Rabbit Class: Fruit Object: Apple, Mango, Kiwi
  • 10.
    • For anycomputer program, two core elements are data and function. • Structured/ procedural programming views these two core element as two separate entities; whereas object-oriented programming views them as single entity. • In procedural programming, data can be altered by any component of the program. It is not protected from modification. • In Object Oriented Programming, this problem can be solved using encapsulation. Presented by Nuzhat Ibrahim Memon 10 Data Data Data Procedure Programming Object 2 Object 1 Object 3 Data Data Data Object Oriented Programming
  • 11.
    • Data andmethod that manipulate data are guarded against modification or misuse by other components of the program. • This mechanism of providing protection to data and methods of a program is called encapsulation. • This is possible by wrapping data and methods into a single unit known as class and declaring them as private. • Private members of the class are not available directly to outside world. If necessary , the data is made available via public methods. • Thus, encapsulation provides data hiding capabilities. • Encapsulation keeps the data safe from unintended actions and inadvertent access by outside objects. Presented by Nuzhat Ibrahim Memon 11 Class Data / Variable Function / Methods/ Behavior
  • 12.
    • Data abstractionis a process of representing the essential features of the objects without including implementation detail. • Abstraction is a concept that hides complexity; it says what it does, but not how it is done. • Data abstraction is a technique that relies on the separation of interface and implementation. • Data abstraction provides the skeleton or templates for our use. • The system hides certain details of how data is stored, created and maintained. • Examples of data abstraction • Abstract Data Types(ADT) or Structures (struct) in C/C++ • classes in C++/Java • In ADT, we simply define a data type and set of operation on it. We do not show the implementation of operations. Presented by Nuzhat Ibrahim Memon 12
  • 13.
    • Encapsulate protectsdata by making them inaccessible from outside. • Abstraction enables to represent data in which the implementation details are hidden (abstracted). Presented by Nuzhat Ibrahim Memon 13
  • 14.
    • Different classesmay have same methods with same name. • Date class->display() , display the date object in specific format • Time class->display(), to display time in specific format • person class -> display() to display the details of person • In object-oriented termixnology, a call to a method is referred to as a message. • When method ‘display’ is invoked in the program, how to know which method is to be executed? • This is determined using the object that invokes the method. • Due to encapsulation, all method calls are handled by objects that recognize the method • For eg. If ‘display’ is called by an object of ‘person’ class, it executes the display method defined in ‘person’ class. Presented by Nuzhat Ibrahim Memon 14 class date class time class person void display(){ System.out.println (“Display the date object in specific format”); } void display(){ System.out.println (“Display the time in specific format”); } void display(){ System.out.println (“Display the details of person”); } date d_obj = new date(); time t_obj = new time(); person p_obj = new person(); d_obj.display(); t_obj,display(); p_obj.display();
  • 15.
    Presented by NuzhatIbrahim Memon 15 • Polymorphism means ‘many forms’. • The polymorphism is achieved using two type of overloading: function overloading and operator overloading. • The capability of using same names to mean different things in different contexts is called overloading. Operator Overloading Function Overloading Polymorphism
  • 16.
    Presented by NuzhatIbrahim Memon 16 • Function or method overloading • It is possible to define more than one function with the same name in object-oriented programming. • The methods differs in signatures( number and type of parameters) • Object- oriented programming allows defining more than one method having same name but different signatures in a single class. This feature is known as function or method overloading. • Operator overloading • Object oriented programming also allows writing expression using operators on objects. • Date d1 – date d2 and n1- n2; operator ‘-’ is performing in a different way. • The same operation is given different meanings upon the data type of operands used. This type of polymorphism is achieved through operator overloading. Operator ‘+’ 2 + 2 = 4 ‘in’ + ‘dia’ = ‘India’ Operator ‘-’ n1 - n2 date d1 – date d2 Area (l,w) Area (pi,r,r) Shape Area ( *b*h) Max (int, int){ return int; } Max (array, size){ return int; }
  • 17.