28
An Introduction to Object Oriented Programming Muhammad Adil Raja Introduction Abstraction Object Oriented Design Classes and Methods Messages, Instances and Initialization Inheritance and Substitution Subclasses and Subtypes AN I NTRODUCTION TO OBJECT ORIENTED P ROGRAMMING (OOP) ACOURSE OUTLINE Muhammad Adil Raja Roaming Researchers, Inc. cbnd March 31, 2015

An Introduction to Object Oriented Programming

Embed Size (px)

Citation preview

Page 1: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

AN INTRODUCTION TO OBJECT ORIENTED

PROGRAMMING (OOP)A COURSE OUTLINE

Muhammad Adil Raja

Roaming Researchers, Inc.

cbndMarch 31, 2015

Page 2: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

OUTLINE I

1 INTRODUCTION

2 ABSTRACTION

3 OBJECT ORIENTED DESIGN

4 CLASSES AND METHODS

5 MESSAGES, INSTANCES AND INITIALIZATION

6 INHERITANCE AND SUBSTITUTION

7 SUBCLASSES AND SUBTYPES

8 STATIC AND DYNAMIC BEHAVIOR

9 IMPLICATIONS OF SUBSTITUTION

10 MULTIPLE INHERITANCE

11 POLYMORPHISM AND SOFTWARE REUSE

12 OVERLOADING

13 OVERRIDING

14 THE POLYMORPHIC VARIABLE

15 GENERICS

Page 3: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

OUTLINE II

16 CONTAINER CLASSES

17 FRAMEWORKS

18 OBJECT INTERCONNECTIONS

19 DESIGN PETTERNS

20 REFLECTION AND INTROSPECTION

21 DISTRIBUTED OBJECTS

22 IMPLEMENTATION

23 REFERENCES

Page 4: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

INTRODUCTION I

What is OOP?

Why is it popular?

Benefits of OOP.

Messages and methods.

Hierarchies and inheritance.

Page 5: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

ABSTRACTION I

Layers of abstraction.

Encapsulation and interchangeability.

Interface and Implementation.

Abstract data types.

Messages, inheritance and polymorphism.

Page 6: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

OBJECT ORIENTED DESIGN I

Components.

Page 7: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

CLASSES AND METHODS I

Encapsulation.Class definitions.C++, Java, and C-sharp.Methods.Constant and immutable data fields.Separating definition and implementation.Variations on Class themes.Methods without classes.Interfaces.Properties.Forward definitions.Inner or nested classes.Class data fields.Classes as objects.

Page 8: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

MESSAGES, INSTANCES AND INITIALIZATION I

Message-passing syntax.

Statically and dynamically typed languages.

Accessing the receiver from within method.

Object creation.

Creation of arrays of objects.

Pointers and memory allocation.

Memory recovery.

COnstructors.

The orthodox canonical class form.

Constant values.

Destructors and finalizers.

Metaclasses.

Page 9: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

INHERITANCE AND SUBSTITUTION I

An intuitive description of inheritance.

The is-a test.

Reasons to use inheritance.

Inheritance in various languages.

Subclass, subtype, and substitution.

Substitution and strong typing.

Overriding and virtual methods.

Interfaces and abstract classes.Forms of inheritance.

1 Subclassing for specialization (subtyping).2 Subclassing for specification.3 Subclassing for construction.4 Subclassing for generalization.5 Subclassing for extension.

Page 10: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

INHERITANCE AND SUBSTITUTION II

6 Subclassing for limitation.7 Subclassing for variance.8 Subclassing for combination.9 SUmmary.

Variations on inheritance.

Anonymous classes in Java.

Inheritance and constructors.

Virtual destructors.

The benefits of inheritance.

Virtual destructors.The benefits of inheritance.

1 Software reusability.2 Code sharing.3 Consistency of inheritance.4 Software components.

Page 11: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

INHERITANCE AND SUBSTITUTION III

5 Rapid prototyping.6 Polymorphism and frameworks.7 Information hiding.

The costs of inheritance.1 Execution speed.2 Program size.3 Message-passing overhead.4 Program complexity.

Page 12: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

SUBCLASSES AND SUBTYPES I

Substitutability.

Subtypes.

The substitutability paradox.

Subclassing for construction.

Dynamically typed languages.

Pre- and Postconditions.

Refinement semantics.

Page 13: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

STATIC AND DYNAMIC BEHAVIOR I

Static versus dynamic typing.

Static and dynamic classes.

Runtime type determination.

Down casting (reverse polymorphism).

Run-time testing without language support.

Testing message understanding.

Static versus dynamic method binding.

Page 14: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

IMPLICATIONS OF SUBSTITUTION I

Memory layout.

Minimum static space allocation.

Maximum static space allocation.

Dynamic memory allocation.

Assignment.

Assignment in C++

Copies and clones.

Copies in Smalltalk and Objective-C.

Copy constructors in C++.

Cloning in java.

Equality.

Equality and identity.

The paradoxes of equality testing.

Page 15: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

MULTIPLE INHERITANCE I

Inheritance as categorization.

Incomparable complex numbers.

Problems arising from multiple inheritance.

Name ambiguity.

Multiple inheritance of interfaces.

Inheritance from common ancestors.

Inner classes.

Page 16: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

POLYMORPHISM AND SOFTWARE REUSE I

Polymorphism in programming languages.

Mechanisms for software reuse.

Using composition.

Using inheritance.

Efficiency and polymorphism.

Page 17: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

OVERLOADING I

Type signatures and scopes.

Overloading based on scopes.

Overloading based on type signatures.

Redefinition.

Multi-methods.

Overloading based on values.

Page 18: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

OVERRIDING I

Notating overriding.

Replacement versus refinement.

Deferred methods.

Covariance and contravariance.

Variations in overriding.

FInal methods in java.

Versioning in C-sharp.

Page 19: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

THE POLYMORPHIC VARIABLE I

Simple polymorphic variables.

The receiver variable.

Downcasting.

Pure polymorphism.

Page 20: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

GENERICS I

Template functions.

Template classes.

Inheritance in template arguments.

Page 21: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

CONTAINER CLASSES I

Containers in dynamically types languages.

Containers in statically types languages.

Restricting element types.

Element traversal.

Page 22: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

FRAMEWORKS I

Reuse and specialization.

An upside-down abstractions.

Example frameworks.

Page 23: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

OBJECT INTERCONNECTIONS I

Coupling and cohesion.

Subclass clients and user clients.

Control of access and visibility.

Intentional dependency.

Page 24: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

DESIGN PATTERNS I

Controlling information flow.

Describing patterns.

Iterator.

Software factory.

Strategy.

Singleton.

Composite.

Decorator.

The double-dispatching pattern.

Flyweight.

Proxy.

Facade.

Observer.

Page 25: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

REFLECTION AND INTROSPECTION I

Mechanisms for understanding.

Methods as objects.

Mechanisms for for modification.

Metaclasses.

Page 26: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

DISTRIBUTED OBJECTS I

Addresses, ports and sockets.

A simple client/server program.

Multiple clients.

Transmitting objects over a network.

Providing more complexity.

Page 27: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

IMPLEMENTATION I

Compilers and interpreters.

The receiver as argument.

Inherited methods.

Overridden methods.

Name encoding.

Dispatch tables.

Bytecode interpreters.

Just-in-time compilation.

Page 28: An Introduction to Object Oriented Programming

AnIntroduction

to ObjectOriented

Programming

MuhammadAdil Raja

Introduction

Abstraction

ObjectOrientedDesign

Classes andMethods

Messages,InstancesandInitialization

InheritanceandSubstitution

SubclassesandSubtypes

REFERENCES I

An Introduction to Object Oriented Programming,Timothy Budd.