1-Object Oriented Programming Development-University of Luton

Embed Size (px)

Citation preview

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    1/21

    1

    Object Oriented Programming

    Development

    By:

    Marc Conrad

    University of Luton

    Email:

    [email protected]:

    D104

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    2/21

    2

    What are we doing today?

    Introduction of:

    the lecturer

    ObjectsBasic Terminology

    C++

    the module

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    3/21

    3

    What is Object Oriented

    Programming?

    An object is like ablack box.

    The internaldetails arehidden.

    Identifying objectsandassigning responsibilitiesto

    these objects.Objects communicate to

    other objects by sendingmessages.

    Messages are received bythe methodsof an object

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    4/21

    4

    What is an object?

    Tangible Things as a car, printer, ...

    Roles as employee, boss, ...

    Incidents as flight, overflow, ...

    Interactions as contract, sale, ...

    Specifications as colour, shape,

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    5/21

    5

    So, what are objects?

    an object represents an individual,identifiable item, unit, or entity, either

    real or abstract, with a well-defined rolein the problem domain.

    Or

    An "object" is anything to which aconcept applies.

    Etc.

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    6/21

    6

    Why do we care about

    objects?

    Modularity - large software projectscan be split up in smaller pieces.

    Reuseability - Programs can beassembled from pre-written softwarecomponents.

    Extensibility - New softwarecomponents can be written ordeveloped from existing ones.

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    7/21

    Example: The Person class

    #include

    #includeclass Person{

    char name[20];

    int yearOfBirth;

    public:

    void displayDetails() {

    cout

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    8/21

    8

    The two parts of an object

    Object = Data + Methods

    or to say the same differently:

    An object has the responsibility to knowandthe responsibility to do.

    = +

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    9/21

    9

    Basic Terminology

    Abstractionis the representation of theessential features of an object. These are

    encapsulated into an abstract data type.Encapsulationis the practice of including

    in an object everything it needs hidden

    from other objects. The internal state isusually not accessible by other objects.

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    10/21

    10

    Basic Terminology:

    Inheritance

    Inheritance means that one class inheritsthe characteristics of another class.

    This is also called a is a relationship:

    A car is avehicle

    A teacher is aperson

    A dog is ananimal

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    11/21

    11

    Basic Terminology:

    Polymorphism

    Polymorphism means having manyforms. It allows different objects to

    respond to the same message in differentways, the response specific to the type ofthe object.

    E.g. the message displayDetails()of thePerson class should give different resultswhen send to a Student object (e.g. theenrolment number).

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    12/21

    12

    Basic Terminology:

    Aggregation

    Aggregation describes a hasarelationship. One object is a part of

    another object.

    We distinguish between composite

    aggregation (the composite owns thepart) and sharedaggregation (the part is

    shared by more then one composite).

    A car has wheels.

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    13/21

    13

    Basic Terminology:

    Behaviour and Messages

    The most important aspect of an object isits behaviour(the things it can do). A

    behaviour is initiated by sending amessageto the object (usually by callinga method).

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    14/21

    14

    The two steps of Object

    Oriented Programming

    Making Classes:Creating, extending orreusing abstract data types.

    Making Objects interact:Creating objectsfrom abstract data types and defining

    their relationships.

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    15/21

    15

    Historical Notes

    C++ owes most to C.Other ancestors are Simula67and Algol68.

    First versions of C++ in 1980 under thename C with classes. Since 1983 thename C++ is used.

    1990: ANSI/ISO 9899 defines a standardfor C

    1998: ISO/IEC 14882 specifies the

    standard for C++

    C++ 1987

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    16/21

    16

    C++ and C

    C is a subset of C++.Advantages:Existing C libraries can be

    used, efficient code can be generated.But:C++ has the same caveats andproblems as C (e.g. pointer arithmetic,).

    C++ can be used both as a low levelandas a high levellanguage.

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    17/21

    17

    C++ and Java

    Java is a full object oriented language, allcode has to go into classes.

    C++ - in contrast - is a hybrid language,capable both of functional and objectoriented programming.

    So, C++ is more powerful but alsomore difficult to handle than Java.

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    18/21

    18

    Module Outline

    Introduction

    The non object

    oriented basicsClasses

    Design Approaches

    Testing

    Inheritance

    Aggregation

    PolymorphismMultifile Development

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    19/21

    19

    Assessment Details

    50% in course and 50% exam.

    For more details for the in course

    assignment see separate handout.

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    20/21

    20

    Books

    Teach Yourself C++ in 10 minutes,J. Liberty, SAMS 1999.

    C++ - How to program, Deitel & Deitel,Prentice Hall, 2001.

    Object Oriented Programming with C++,

    David Parson, Letts Educational, London1997.

  • 7/29/2019 1-Object Oriented Programming Development-University of Luton

    21/21

    21

    Websites

    A C++ online tutorial:http://www.cplusplus.com/doc/tutorial/

    The C++ FAQ:http://www.parashift.com/c++-faq-lite

    The homepage of Bjarne Stroustrup, the

    inventor of C++:http://www.research.att.com/~bs