EE441 Data Structures (Fall 2001) - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

EE441 Data Structures (Fall 2001)

Description:

Change a data item (color, engine, etc.) Display data items. Calculate cost. etc. Example (Automobile): CFB'2005. EE-441 Data Structures. 16. Examples of Objects ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 23
Provided by: ozgurba
Category:
Tags: data | ee441 | fall | structures

less

Transcript and Presenter's Notes

Title: EE441 Data Structures (Fall 2001)


1
EE441 Data Structures(Fall 2001)
  • Cüneyt F. Bazlamaçci
  • Department of Electrical Electronics
    Engineering
  • Middle East Technical University
  • cuneytb_at_metu.edu.tr
  • www.eee.metu.edu.tr/cb

2
Course Outline (Tentative)
  • Introduction to OOP
  • Abstract Data Types, Classes Objects
  • Arrays
  • Complexity of algorithms
  • Stacks
  • Queues
  • Dynamic memory management
  • Linked Lists
  • Trees, B-Trees
  • Sorting and Hashing Algorithms

3
Administrative Details
  • Instructor (Section IV) Cüneyt F. Bazlamaçci
  • Office EA-406
  • Email cuneytb_at_metu.edu.tr
  • Course Web Follow http//www.eee.metu.edu.tr/cb/
  • Office Hours Anytime!
  • Attendance will be taken but it will not affect
    your grade! (thus, no sleeping in the CR, o/w
    youll be kindly invited to sleep outside.)

4
Chapter IIntroduction to OOP
5
Object-Orientation
  • We perceive the world as a world of objects
  • You look around and see a chair, a table, a
    person, and the objects are related in one way or
    another.
  • The object-oriented technique tries to imitate
    the way we think
  • A system developed by using the object-oriented
    technique can be seen as a system consisting of a
    number of objects which cooperate to solve a
    task.

6
A Shift in Thinking ?
  • A fundamental change in approach
  • Structured programming reflects the way that
    computers process information (e.g. sequential
    execution, conditional branching and repetition).
    As such, a problem is tackled by decomposing it
    into a flow of operations, data is of secondary
    importance.
  • we do not naturally think in this way ? dealing
    with complex problems is difficult and bugs may
    not be obvious
  • OO approach attempts to find a methodology and
    language that reflect the way that people think
    about problems.
  • In fact, it appears that people tend to think in
    terms of things not operations.
  • In OO development we refer to these "things" as
    objects

7
Structured vs. OO Programming
STRUCTURED PROGRAMMING
8
Structured Programming
  • Using function
  • Function program is divided into modules
  • Every module has its own data and function which
    can be called by other modules.

9
A New Approach
  • Software developers sought a new approach for
    developing software. One that would . . .
  • Produce highly maintainable software, where
    changing one part of a program would not break
    the rest
  • Produce reusable software, where similar
    programming tasks could share common elements,
    without having to reinvent the wheel
  • Make it easier to tackle complex programming
    problems and reduce the chances of introducing
    bugs into programs.
  • These ideas led to the development of
    object-oriented (OO) software development.

10
OO Approach
  • OO development starts by thinking about the
    problem, and not about the program that will
    implement the solution
  • In the real world, "things" have characteristics
    and behavior.
  • e.g. a car is a "thing" that has a make, model,
    registration number and can accelerate, steer,
    brake, change gear etc.
  • When we think about the objects involved in the
    problem, we actually think about their
    characteristics (attributes) and behavior
  • An object-oriented language will allow us to
    model these attributes and behaviors.
  • We construct a solution to the problem from these
    objects

11
OO Programming
  • A design and programming technique
  • Objects have both data and methods
  • Objects of the same class have the same data
    elements and methods
  • Objects send and receive messages to invoke
    actions
  • Key idea in object-oriented programming
  • The real world can be accurately described as a
    collection of objects that interact with each
    other
  • Pure OO Languages Smalltalk, Eiffel, Actor, Java
  • Hybrid OO Languages C, Object-Pascal

12
Structured vs. OO Programming (Recap.)
STRUCTURED PROGRAMMING
13
OO Programming
14
Some OOP Terminology
  • object - usually a person, place or thing (a
    noun)
  • method - an action performed by an object (a
    verb)
  • class - a category of similar objects (such as
    automobiles)
  • Class does not hold any values of the objects
    attributes

15
Example of an Object Class
Example (Automobile)
  • Methods
  • Define data items (specify manufacturers name,
    model, year, etc.)
  • Change a data item (color, engine, etc.)
  • Display data items
  • Calculate cost
  • etc.
  • Attributes
  • manufacturers name
  • model name
  • year made
  • color
  • number of doors
  • size of engine
  • etc.

16
Examples of Objects
  • What the objects are, will be determined by the
    problem domain
  • In a banking application
  • customers, accounts, sums of money etc.
  • In a library application
  • books, journals, CD-Roms, members, etc.
  • In a network simulator
  • network nodes, queues, links, data packets etc.

17
Why OOP?
  • Save development time (and cost) by reusing code
  • once an object class is created it can be used in
    other applications
  • Easier debugging
  • classes can be tested independently
  • reused objects have already been tested

18
Design Principles of OOP
  • Three main design principles of Object-Oriented
    Programming(OOP)
  • Encapsulation
  • Polymorphism
  • Inheritance

19
Encapsulation
  • Encapsulation to design, produce, and describe
    software so that it can be easily used without
    knowing the details of how it works.
  • Also known as data hiding
  • Only objects function which perform parts of the
    objects behavior can modify information in the
    object.
  • An analogy
  • When you drive a car, you dont have to know the
    details of how many cylinders the engine has or
    how the gasoline and air are mixed and ignited.
  • Instead you only have to know how to use the
    controls.

20
Polymorphism
  • Polymorphism the same word or phrase can mean
    different things in different contexts
  • Analogy
  • in English, bank can mean side of a river or a
    place to put money
  • Function Overloading
  • The operation of one function depends on the
    argument passed to it.
  • Example Fly(), Fly(low), Fly(150)

21
Inheritance
  • Inheritance a way of organizing classes
  • Term comes from inheritance of traits like eye
    color, hair color, and so on.
  • Classes with properties in common can be grouped
    so that their common properties are only defined
    once.
  • Superclass provides its attributes methods to
    the subclass(es).
  • Subclass inherits all its superclass attributes
    methods besides having its own unique
    attributes methods.

22
An Inheritance Hierarchy
Superclass
Vehicle
Subclasses
Automobile
Motorcycle
Bus
Sedan
Sports Car
School Bus
Luxury Bus
Write a Comment
User Comments (0)
About PowerShow.com