OBJECT ORIENTED PROGRAMMING - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

OBJECT ORIENTED PROGRAMMING

Description:

OBJECT ORIENTED PROGRAMMING What is Object Oriented Software? Software based on the creation of objects An object is a black box which receives and sends ... – PowerPoint PPT presentation

Number of Views:153
Avg rating:3.0/5.0
Slides: 34
Provided by: unt68
Category:

less

Transcript and Presenter's Notes

Title: OBJECT ORIENTED PROGRAMMING


1
OBJECT ORIENTED PROGRAMMING
2
What is Object Oriented Software?
  • Software based on the creation of objects
  • An object is a black box which receives and
    sends messages
  • A black box contains code and data, which are
    merged into a single indivisible object
  • As a user - Do not peek into the box!

3
Why is it so famous?
  • Offers a new and powerful model for writing
    computer software
  • Improves maintenance, reusability and
    modifiability
  • Improves principles of modularity and information
    hiding.

4
POINTS OF DISCUSSION
  • Object
  • Message
  • Event
  • Class
  • Property
  • Inheritance
  • Data Abstraction and Encapsulation

5
INTRODUCTION
  • Object Oriented Programming models real-world
    objects with software counterparts, H.M.Deitel
    P.J.Deitel
  • It is a type of programming where a programmer
    defines both data types and functions of a data
    structure.

6
What is an Object?
  • OOP encapsulates data and functions into packages
    called objects, that are intimately tied
    together.
  • Objects are individual instances of a class.

7
So, what is a class?
  • It determines everything about an object.
  • Spot is an object created from class Dog.
  • A method is simply the action that a message
    carries out.
  • The Dog class defines messages that the Dog
    objects can understand, like bark and fetch.

8
Message
  • Messages define the interface to the object
  • All communication to the object is done via the
    messages
  • Objects do not ordinarily perform their behavior
    spontaneously, rather a specific behavior is
    invoked when a message is sent.

9
PROPERTY AND EVENTS
  • An event is a signal for the object to perform
    its function
  • Properties are defined characteristics of the
    object

10
PROPERTIES
  • Take advantage of class relationships, where
    objects of a certain class have the same
    characteristics
  • Provide a more natural and intuitive way of
    viewing the programs progress
  • Encapsulate data and functions into objects

11
INHERITANCE
  • Inheritance is a form of software reusability
    in which new classes are created from existing
    classes by the absorption of attributes and
    behaviors, embellishing these with capabilities
    the new class requires.

12
INHERITANCE
  • In any good Object Oriented language, the
    programmer creates a subclass of the original
    class. This new class inherits all the existing
    messages, and therefore, all the behavior of the
    original class.
  • The original class is called the parent class or
    Super class, of the new class.
  • A subclass is said to be a specialization of its
    super class, and conversely, a super class a
    generalization of its subclass.

13
INHERITANCE
  • Promotes reuse
  • Programmers dont start from the scratch when
    they write a new program. They reuse an existing
    repertoire of classes that have behaviors similar
    to what is required in the new program.
  • For example, after creating the class Dog, you
    might create a subclass called Wolf, which
    defines some wolf specific messages such as hunt.

14
INHERITANCE
  • It is more sensible to define a common class
    called Canine, of which both Dog and Wolf are sub
    classes
  • Much of the art of OOP is determining the best
    way to divide a program into an economical set of
    classes.
  • In addition to speeding development time, proper
    class construction and reuse results in far fewer
    lines of code, which translates to less bugs, and
    lower maintenance costs.

15
DATA ABSTRACTION
  • Loosely defined category of objects that can be
    manipulated and used in a variety of different
    programs.

16
DATA ENCAPSUALTION
  • Providing access to an object only through its
    messages, while keeping the details private

17
A SIMPLE EXAMPLE
  • Suppose, you wanted a data type called list(list
    of names)
  • Struct list
  • ltdefinition of list structure heregt
  • List a, b, c
  • a Mary Jones
  • b Suzy Smith

18
A SIMPLE EXAMPLE
  • In C, adding the integers a and b produces an
    error the language doesnt know what to do with
    a and b because they are not numeric entities.
    They are strings

19
A SIMPLE EXAMPLE
  • aList fromString Mary Jones.
  • bList fromString Suzy Smith.
  • Cab.
  • Output
  • Mary Jones, Suzy Smith

20
A SIMPLE EXAMPLE
  • The first two lines of code simply create List
    objects a and b from the two strings. This now
    works, because the list class was created with a
    method which specifically knows how to handle
    the message . Hence, C will have the new value
    of a combination of the argument with its own
    object by striking them together with a comma
    separating them.
  • Mary Jones, Suzy Smith

21
OBJECT ORIENTED LANGUAGES
  • There are almost two dozen of them today!
  • The leading commercial OOLs are
  • C
  • Smalltalk
  • Java
  • C is an OO version of C
  • Smalltalk is significantly faster to develop than
    C
  • Java is the latest, flashiest OO language

22
C - OBJECT ORIENTED LANGUAGE
  • C is compatible with C (superset of C), so
    that existing code can be incorporated into C
    programs. C programs are fast and efficient,
    qualities which helped make C an extremely
    popular programming language. It sacrifices
    certain flexibility in order to remain efficient

23
C - OBJECT ORIENTED LANGUAGE
  • C uses compile-time binding, which means the
    programmer must specify the specific class of an
    object, which makes for high run-time efficiency
    and small code size, but it trades off some of
    the power to reuse the classes.
  • C has become so popular that most new compilers
    are C/C compilers.

24
C - OBJECT ORIENTED LANGUAGE
  • However, in order to take full advantage of OOP,
    one must program in C, not C.
  • This often can be a major problem for C
    programmers.
  • Many programmers think they are coding in C,
    but instead are only using a small part of the
    languages object oriented power!

25
Smalltalk - OBJECT ORIENTED LANGUAGE
  • C makes some practical compromises to ensure
    fast execution and small code size, Smalltalk
    makes none.
  • It uses run-time binding, which means that
    nothing about the type of an object need be known
    before a Smalltalk program is run.
  • Smalltalk has a rich class library that can be
    easily reused via inheritance.

26
Smalltalk - OBJECT ORIENTED LANGUAGE
  • It also has a dynamic development environment
  • Smalltalk is not explicitly compiled, like C
  • It is syntactically very simple, much more so
    than either C or C.

27
Java - OBJECT ORIENTED LANGUAGE
  • Java is designed as a portable language that can
    run on any web-enabled computer via that
    computers web browser. As such, it offers great
    promise as the standard internet and intranet
    programming language.
  • Java is a mixture of C and Smalltalk!
  • It has no pointers, low-level programming
    constructs that make error-prone programs.

28
Java - OBJECT ORIENTED LANGUAGE
  • Like Smalltalk, Java has garbage collection, a
    feature that frees the programmer from explicitly
    allocating and de-allocating memory.
  • It runs on a Smalltalk-style virtual machine,
    software built into web browser which executes
    the same standard compiled Java byte codes
    irrespective of the computer used.

29
Powerbuilder - OBJECT ORIENTED LANGUAGE
  • PowerBuilder is an object oriented application
    tool that allows to build powerful, multitier
    applications to run on multiple platforms and to
    interact with various databases.
  • Each menu or window you create is an object.
  • Each object contains properties, events and
    functions.

30
SUMMARY
  • An object is a bundle of variables and related
    methods
  • A method is an operation which can modify an
    objects behavior.
  • A Class is a blueprint of an object.
  • When defining a Class, you must consider any
    possible sub class.

31
CONCLUSION
  • Major advantages of OOP are
  • It can address the problems that increasing size
    and complexity cause
  • Produce more complete and understandable
    specifications and designs by using all major
    types of data abstraction
  • This approach speeds up the development of new
    programs, improves maintenance and reusability.

32
CONCLUSION
  • However, OOP requires a major shift in thinking
    by programmers.
  • The C offers an easier transition via C, but
    it still requires an OO design approach.
  • Java promises much for web-enabling OO programs.
  • Smalltalk offers a pure OO environment.

33
BIBLIOGRAPHY
  • C How to Program - Deitel Deitel
  • Object Oriented Analysis - David Brown
  • Object Oriented Analysis and Design with
    applications - Grady Booch
  • What is Object-Oriented Software? An article by
    Terry Montlick
  • Design, Implementation and Management - Peter Rob
    Carlos Coronel.
Write a Comment
User Comments (0)
About PowerShow.com