Top Banner

of 15

Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

Apr 05, 2018

Download

Documents

JOna Lyne
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    1/15

    PROGRAMMING PARADIGM

    Style of Programming in which the programming task isbroken down into a series of operations (calledprocedures) applied to data (or data structures)

    C and Pascal

    2. Object-Oriented Programming

    Extension of procedural programming

    Breaks down a programing task into a series ofinteractions among different entities or objects

    Java, C++, and Smalltalk

    1. Procedural Programming

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    2/15

    OBJECT ORIENTED PROGRAMMING

    Type of programming in which programmers definenot only the data stuctures, but also the types ofoperations (methods) that can be applied to the datastuctures.

    Enables programmers to create modules that do notneed to be changed when a new type of object isadded.

    Most widely used paradigm

    Instead of focusing on what the system has to do,focus on:

    what objects the system containshow they interact towards solving the

    programming problem

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    3/15

    ILLUSTRATION OF OOP

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    4/15

    OBJECT ORIENTED PROGRAMMING

    Advantages of OOP over Conventional Approaches:it provides a clear modular structure for programs

    which makes it good for defining abstract data typeswhere implementation details are hidden and the unithas a clearly defined interface.

    it makes it easy to maintain and modify existing codeas new objects can be created with small differencesfrom existing ones.

    it provides a good framework for code librarieswhere supplied software components can be easilyadapted and modified by the programmer. This isparticularly useful for developing graphical userinterfaces.

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    5/15

    OBJECT ORIENTED PROGRAMMING

    Key OOP Concepts:Objects

    Classes

    Inheritance

    Encapsulation

    Polymorphism

    Abstraction

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    6/15

    OBJECT AND CLASSES Objects

    Represent things from the real world

    Made up ofAttributes characteristics that define an objectMethods self-contained block of program code

    similar to procedureExample:

    A cars attributes are make, model, year, & purchase priceA cars methods are forward and backward

    Define a type of object

    ClassesTerm that describes a group or collection of objects

    with common properties

    Specifies methods and data that type of objects has

    Example:

    EmployeeCar

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    7/15

    ABSTRACTION

    Allows a programmer to hide all but the relevant

    information (to the problem at hand) about an objectin order to reduce complexity and increase efficiency

    Closely related to encapsulation and informationhiding

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    8/15

    ENCAPSULATION

    refers to the hiding of data (attributes) and

    methods within an object

    protects an objects data from corruption

    protects the objects data from arbitrary and

    unintended use hides the details of an objects internal

    implementation from the users of an object

    separates how an object behaves from how it is

    implemented.

    easier to modify programs since one object type ismodified at a time.

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    9/15

    ILLUSTRATION OF ENCAPSULATION

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    10/15

    INHERITANCE

    the process by which objects can acquire (inherit)

    the properties of an ojects of other class

    Provides reusability, like adding additional features

    to an existing class without modfying it.

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    11/15

    INHERITANCE

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    12/15

    POLYMORPHISM

    refers to the ability to process objects differently

    depending on their data type or class

    the ability to redefine methods for derived classes

    request for an operation can be made withoutknowing which specific method should be invoked

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    13/15

    POLYMORPHISM

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    14/15

    ABSTRACT CLASSES

    Class that is not used to creare (instantiate) objects

    designed to act as a base class (to be inherited by

    other classes)

    design concept in program development andprovides a base upon which other classes are built.

    can only specify members that shoukd beimplemented by all inheriting classes

  • 7/31/2019 Week 1 Sessions 1-2 Slides 1-15 Introduction to OOP

    15/15

    INTERFACES

    Allow you to create definitions for component

    interaction

    provide another way of implementing

    polymorphism

    specify methods that a component must implementwithout actually specifying how the method isimplemented