: Maha Sabri Altememe Lecturer : Maha Sabri Altememe Lecture :1 1

download : Maha Sabri Altememe Lecturer : Maha Sabri Altememe Lecture :1 1

If you can't read please download the document

  • date post

    17-Jan-2016
  • Category

    Documents

  • view

    228
  • download

    6

Embed Size (px)

Transcript of : Maha Sabri Altememe Lecturer : Maha Sabri Altememe Lecture :1 1

  • Lecturer : Maha Sabri Altememe

    Lecture :1

    *

  • The 1960s gave birth to structured programming. This is the method encouraged by languages such as C and Pascal. The use of structured languages made it possible to write middling complex programs fairly easily. Structured languages are characterized by their support for stand-alone subroutines, local variables, rich control constructs, and their lack of reliance upon the GOTO. Although structured languages are a powerful tool, even they reach their limit when a project becomes too large. *Introduction to Object-Oriented Programming

  • Object oriented programming involves programming using objects. An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life. This lesson explains how state and behavior are represented within an object, introduces the concept of data encapsulation, and explains the benefits of designing your software in this manner. For example, a student, circle.

    *What Is Object-Oriented Programming?

  • *Concept: Object have state and behaviors The state of an object is represented by data fields with their current values .The behavior of an object is defined by a set of methods.

    A class can be defined as a template that describes the behaviors that object of its type support.Every object belongs to (is an instance of) a classAn object may have fields, or variables(The class describes those fields)An object may have methods(The class describes those methods)

  • * ObjectsIs a bank account an object? Is an account no. an object?Is a checking account an object?

  • *Example of a classpublic class Student { String name; int age;

    void getname(){ } void setage(){ } }

  • To support the principles of object-oriented programming, all OOP languages have three features in common: EncapsulationPolymorphism Inheritance.

    *Fundamental Principles of OOP

  • Encapsulation is used to hide the values or state of a structured data object inside a class. That is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. In an object-oriented language, code and data may be combined in such a way that a self-contained. When code and data are linked together in this fashion, an object is created. In other words, an object is the device that supports encapsulation. Within an object, code, data, or both may be private to that object or public.

    *Encapsulation

  • *Encapsulation Example

  • Object-oriented programming languages support polymorphism, which is characterized by the phrase "one interface, multiple methods." In simple terms, polymorphism is the attribute that allows one interface to control access to a general class of actions.

    *Polymorphism

  • For example: UndergraduateStudent and GraduateStudent are subclasses of Student

    *Count..

  • Inheritance is the process by which one object can get the properties of another object. This is important because it supports the concept of classification. If you think about it, most knowledge is made manageable by hierarchical classifications. For example, a Red apple is part of the classification apple, which in turn is part of the fruit class, which is under the larger class food. *Inheritance

  • Inheritance let us to create a new class from the existing classes.The new class is called subclass and the existing class is called superclass.The subclass inherits the properties of the superclass.The properties refer to the method or the attribute (data)Inheritance is is-a relationExample: if a Circle inherits the Shape class, hence the Circle is a Shape. (See the next figure)

    *Count..

  • *Count..

  • Single inheritance Is a subclass that derived from a single/one superclass (existing class)Multiple inheritanceIs a subclass that derived from more than one superclassNot supported by Java.

    *Count..

  • *Single Multiple

  • *Q?

    . .

    ***The two most important concepts in object-oriented programming are the class and the object.

    In the broadest term, an object is a thing, both tangible and intangible, which we can imagine.

    A program written in object-oriented style will consist of interacting objects. For a program to maintain bank accounts for a bank, for example, we may have many Account, Customer, Transaction, and ATM objects.

    An object is comprised of data and operations that manipulate these data.

    * . . . . . .

    * . . . . . .

    *