SlideShare a Scribd company logo
1 of 64
Download to read offline
SOFTWARE REUSE

& OBJECT-ORIENTED PROGRAMMING
LINGI2252 – PROF. KIM MENS
* These slides are part of the course LINGI2252 “Software Maintenance and Evolution”,
given by Prof. Kim Mens at UCL, Belgium
*
A. SOFTWARE REUSE
LINGI2252 – PROF. KIM MENS
SOFTWARE REUSE
REUSABILITY [DEFINITION]
Reusability is a general engineering principle whose importance
derives from the desire to avoid duplication and to capture
commonality in undertaking classes of inherently similar tasks.
Source: Peter Wegner, "Capital-Intensive Software Technology", in
Chapter 3 of Software Reusability, Volume I : Concepts and Models,
ACM Press, 1989.
Software reusability is the degree to which a software module or other
work product can be used in more than one software system.
Reusable: pertaining to a software module or other work product that
can be used in more than one computer program or software system.
3
SOFTWARE REUSE
SOFTWARE REUSE [DEFINITION]
Software reuse
The reapplication of a variety of kinds of knowledge about one
system to another in order to reduce the effort of developing or
maintaining that other system.
This “reused knowledge” includes artefacts such as domain
knowledge, development experience, requirements, architectural
components, design artefacts, code, documentation, and so forth.
Source: Software Reusability, Volume I : Concepts and Models, Eds.
Biggerstaff & Perlis, ACM Press, 1989.
4
SOFTWARE REUSE
REUSABLE COMPONENT [DEFINITION]
Software reuse
The process of implementing new software systems using existing
software information.
Reusable component
A software component designed and implemented for the specific
purpose of being reused.
Component can be requirement, architecture, design, code, test data, etc.
Source: Kang & al., Feature-Oriented Domain Analysis (FODA): Feasibility
Study, Technical Report CMU/SEI-90-TR-21, 1990.
5
SOFTWARE REUSE
SOFTWARE REUSE [EXAMPLE]
Using functions available in some library.
E.g., C libraries are collections of precompiled functions
that have been written to be reused by other programmers.
Reusing classes from another object-oriented program.
Adapting the modules of a software system with a very similar
functionality (member of a same “family”).
Reusing the architecture or design of a software system when
porting it to a new language.
6
SOFTWARE REUSE
WHY REUSE?
Economic justification:
more productive by avoiding double work
better quality by reusing good solutions
Intellectual justification:
stand on each other's shoulders
don't reinvent or reimplement old stuff
focus on what's new and relevant
7
SOFTWARE REUSE
SOME REUSE TECHNIQUES
Programming abstractions and mechanisms
procedural and data abstraction

encapsulation and information hiding

code sharing and reuse mechanisms
Design patterns
Software architecture
Software libraries & application frameworks
Generative programming & model-driven development
8
B. OBJECT-ORIENTED PROGRAMMING
LINGI2252 – PROF. KIM MENS
OBJECT-ORIENTED PROGRAMMING
OBJECT-ORIENTED PROGRAMMING PROMOTES MODULARITY AND REUSE
It is often “claimed” that object-oriented programming
is a better way of writing more modular programs
leverages code sharing and design reuse
minimises maintenance costs
Thanks to its abstraction mechanisms
10
OBJECT-ORIENTED PROGRAMMING
ABSTRACTION MECHANISMS
Encapsulation
keep data and operations that act on this data together
Information hiding
isolate and hide design and implementation choices
Polymorphism
allow for different implementations of a same design to co-exist
Code sharing
capture and exploit similarities in data and behaviour

(through inheritance)
11
OBJECT-ORIENTED PROGRAMMING
KEY OBJECT-ORIENTED CONCEPTS
Objects & Classes
Methods & Messages
Polymorphism & Dynamic Binding
Hierarchies of classes
Method overriding, self & super calls
Abstract classes & methods
Different kinds of inheritance
Single, Multiple, Interfaces, Mixins
12
DISCLAIMER
ALTHOUGH WHAT FOLLOWS MAY

SEEM LIKE A CRASH COURSE IN OO

OUR FOCUS WILL LIE ON THE
MECHANISMS IT PROVIDES FOR
ACHIEVING MODULARITY,
MAINTAINABILITY, SHARING AND REUSE
OBJECT-ORIENTED PROGRAMMING
TWO MAIN PRINCIPLES OF OBJECT-ORIENTED PROGRAMMING
Everything is an object
Objects respond only to messages
13
OBJECT-ORIENTED PROGRAMMING
SMALLTALK’S INFLUENCE
Smalltalk is a pure object-oriented language
Was a source of inspiration to many OO languages
Ruby is heavily inspired on Smalltalk
Objective-C and Swift heavily inspired on Smalltalk
Java is heavily influenced by Smalltalk
14
DISCLAIMER
THIS SESSION MAY CONTAIN TRACES OF SMALLTALK CODE

(FOR DIDACTIC PURPOSES)
OBJECT-ORIENTED PROGRAMMING
KEY OBJECT-ORIENTED CONCEPTS
Objects & Classes
Methods & Messages
Polymorphism & Dynamic Binding
Hierarchies of classes
Method overriding, self & super calls
Abstract classes & methods
Different kinds of inheritance
Single, Multiple, Interfaces, Mixins
15
OBJECT-ORIENTED PROGRAMMING
OBJECTS ENCAPSULATE DATA
Every object has its own data or state
Values stored in the objects
(but variables declared in classes)
Data is encapsulated
Protected from the outside world
Only accessible through messages
aPoint
x 5
y 10
16
circumference
aCircle
center •
radius 2
OBJECT-ORIENTED PROGRAMMING
CLASSES ENCAPSULATE BEHAVIOUR
Classes
declare the state of objects

(but objects contain the actual values)
define the behaviour of objects
method implementations
shared among all objects of a class
can manipulate the state directly
Behaviour is encapsulated
invoked by sending message to an object
Circle
center (Point)
radius (Number)
surface π.radius2
circumference 2.π.radius
17
OBJECT-ORIENTED PROGRAMMING
CLASSES ARE FACTORIES OF OBJECTS
A class is a “factory” for producing objects of the same type
e.g., with a Circle class you can create many circle objects
Every object is an instance of the class from which it was created
A class is a blueprint for objects that share behaviour and state
All objects of a class behave in a similar fashion in response
to a same message
Enables reuse of behaviour
18
OBJECT-ORIENTED PROGRAMMING
CLASSES & OBJECTS PROMOTE MODULARITY
Through encapsulation
of both behaviour and state
grouping behaviour with the data it acts upon
facilitates modularity, code reuse and maintenance
19
OBJECT-ORIENTED PROGRAMMING
CLASSES & OBJECTS PROMOTE REUSE
Classes are fine-grained reusable components
that enable sharing and reuse of structure and behaviour
even across applications
for example via application frameworks
or reusable class hierarchies
20
OBJECT-ORIENTED PROGRAMMING
KEY OBJECT-ORIENTED CONCEPTS
▸ Objects & Classes
▸ Methods & Messages
▸ Polymorphism & Dynamic Binding
▸ Hierarchies of classes
▸ Method overriding, self & super calls
▸ Abstract classes & methods
▸ Different kinds of inheritance
▸ Single, Multiple, Interfaces, Mixins
21
OBJECT-ORIENTED PROGRAMMING
METHODS & MESSAGES (RECAP)
Objects (not functions or procedures) are the main building blocks
of OO
Objects communicate through message passing
Objects exhibit behaviour in response to messages sent to
them
The actual behaviour is implemented in methods
Methods specify what behaviour to perform on objects
Methods can manipulate the objects’ internal state
22
OBJECT-ORIENTED PROGRAMMING
POLYMORPHIC METHODS
A same message can be sent to objects of different classes
aCircle.surface aRectangle.surface
Different objects can react differently to the same message
different classes can provide different implementations

for methods with the same name
Circle > surface = π.radius
2

Rectangle > surface = (bottom-top).(right-left)
Responsibility of how to handle the message is decided by the object

(depending on the class to which it belongs)
This is called “polymorphism”
23
OBJECT-ORIENTED PROGRAMMING
ADVANTAGES OF POLYMORPHISM
Cleaner, more maintainable code
Less ≠ method names
Less need for conditionals
More implementation freedom
Each class can decide how best to implement a method
Locality
Every object/class is responsible for its own actions
Easy to change the implementation by another one
24
OBJECT-ORIENTED PROGRAMMING
EXAMPLE OF POLYMORPHISM
Procedural style vs. object-oriented style
Example:
Write some code that calculates the sum of the surfaces of
a collection of different shape objects
surface(collection) = Σshape∈collection surface(shape)
25
OBJECT-ORIENTED PROGRAMMING
EXAMPLE OF POLYMORPHISM (PSEUDOCODE)
Procedural style (no polymorphism)
circleSurface(c) = π.radius(c)2

rectangleSurface(r) = (bottom(r) - top(r)) * (right(r) - left(r))

surface(collection) : Real
total = 0
∀ shape ∈ collection :
if ( shape == Circle ) then
total = total + circleSurface(shape)
else if ( shape == Rectangle ) then
total = total + rectangleSurface(shape)
return total
26
OBJECT-ORIENTED PROGRAMMING
EXAMPLE OF POLYMORPHISM (PSEUDOCODE)
OO style (using polymorphism)
Circle {
Point center ; Real radius ;
Real surface() : { π.radius2
}
}
Rectangle {
Real bottom, top, right, left;
Real surface() : { (bottom-top)*(right-left) }
}
Real surface(collection) : {
total = 0
∀ shape ∈ collection : total = total + shape.surface()
return total

}
27
OBJECT-ORIENTED PROGRAMMING
EXAMPLE OF POLYMORPHISM (PSEUDOCODE)
OO style (using polymorphism)


Real surface(collection) : {
total = 0
∀ shape ∈ collection : total = total + shape.surface()
return total

}

Advantages:
Adding a new shape does not require to change the existing
implementation
No need to know the kind of objects it manipulates as long as they
all share a common interface
28
OBJECT-ORIENTED PROGRAMMING
LATE BINDING
When sending a message, the actual receiver of a message is not
necessarily known until run-time
Mapping of messages to methods is deferred until run-time
depending on which object actually received the message
we call this late binding or dynamic binding
Most traditional languages do this at compile time (static binding)
Smalltalk uses late binding
29
surface
aCircle
aRectangle
aTriangle
OBJECT-ORIENTED PROGRAMMING
EXAMPLE OF LATE BINDING (PSEUDOCODE)
Circle {
Point center ; Real radius ;
Real surface() : { π.radius
2
}
}
Rectangle {
Real bottom, top, right, left;
Real surface() : { (bottom-top)*(right-left) }
}
test() : {
shape = new Circle(new Point(0,0), 2);
print(shape.surface());
shape = new Rectangle(10,10,30,50);
print(shape.surface())
}
polymorphic methods
late bound messages
OBJECT-ORIENTED PROGRAMMING
STATIC VS. DYNAMIC BINDING IN JAVA
Smalltalk uses dynamic binding (a.k.a. late binding)
For Java it depends
Binding of overridden methods happens at runtime (dynamic)
Binding for overloaded methods at compile time (static)
Binding of private, static and final methods at compile time (static)
since these methods cannot be overridden.
Sources:
http://beginnersbook.com/2013/04/java-static-dynamic-binding/
http://stackoverflow.com/questions/19017258/static-vs-dynamic-binding-in-java
31
OBJECT-ORIENTED PROGRAMMING
LATE BINDING EXAMPLE (JAVA)
Source: http://stackoverflow.com/questions/19017258/static-vs-dynamic-binding-in-java
Apart from syntactic differences and
the lack of type declarations in
Smalltalk, this example could be
recreated nearly “as is” in Smalltalk.

In fact for Smalltalk you could even
create an example that doesn’t
require inheritance.
OBJECT-ORIENTED PROGRAMMING
LATE BINDING EXAMPLE IN JAVA
The method call vehicle.start()

is dynamically bound to the
overridden Car > start() method
Because even though vehicle is
typed as being of class Vehicle,
it is determined at runtime that
it contains an object of type Car
and because the method start()
is overridden
OBJECT-ORIENTED PROGRAMMING
STATIC BINDING EXAMPLE IN JAVA
34
Source: http://stackoverflow.com/questions/19017258/static-vs-dynamic-binding-in-java
OBJECT-ORIENTED PROGRAMMING
STATIC BINDING EXAMPLE IN JAVA
The method call et.sort(c)

is statically determined by

the compiler to refer to

the sort(Collection) method
Even though c is an object of type
HashSet and the sort(HashSet) method
is more specific
Because c is statically

determined to have type Collection
and the method sort is overloaded, not
overridden
35
This example cannot be recreated in
Smalltalk since Smalltalk has no
method overloading.

(Nor does it have final methods or
private methods.)
OBJECT-ORIENTED PROGRAMMING
CLASSES & OBJECTS PROMOTE MODULARITY
Through information hiding
restricted access to objects through a well-defined interface
users of an object only know the set of messages it will accept
they do not know how the actions performed in response to a message
are carried out
This is the responsibility of the receiving object (through polymorphism)
improves modularity by hiding implementation details
How the data is represented internally
How the behaviour is implemented in terms of that data
36
OBJECT-ORIENTED PROGRAMMING
KEY OBJECT-ORIENTED CONCEPTS
▸ Objects & Classes
▸ Methods & Messages
▸ Polymorphism & Dynamic Binding
▸ Hierarchies of classes
▸ Method overriding, self & super calls
▸ Abstract classes & methods
▸ Different kinds of inheritance
▸ Single, Multiple, Interfaces, Mixins
37
OBJECT-ORIENTED PROGRAMMING
HIERARCHIES OF CLASSES
Shape
colour (Colour)
Rectangle
bottom top
left right
surface height*width
circumference 2.height+2.width
Circle
center radius
surface π.radius2
circumference 2.π.radius
38
OBJECT-ORIENTED PROGRAMMING
HIERARCHIES OF CLASSES
Classes are typically organised into hierarchical structures
Information (data/behaviour) associated with classes higher in the
hierarchy is automatically accessible to classes lower in the hierarchy
Each subclass specialises the definition of its ancestors
subclasses can use ancestor’s behaviour and state
subclasses can add new state and behaviour
subclasses can specialise ancestor behaviour
subclasses can override ancestor’s behaviour
39
OBJECT-ORIENTED PROGRAMMING
HIERARCHIES OF CLASSES
Inheritance is a powerful incremental reuse mechanism
Often you don’t want to rewrite everything; you just want some
small changes to what exists
Classes are the units of reuse
Inheritance is the reuse mechanism
e.g., extends keyword in Java :

class Automobile extends LandVehicle
Class hierarchies are ideal for sharing declarations and
implementation among classes
Object’s state and behavioural description is broken into
pieces and distributed along specialisation paths
Promotes encapsulation, modularity, and reusability
Container
colour contents
Vehicle
velocity location
LandVehicle
wheels
Automobile
brand
40
OBJECT-ORIENTED PROGRAMMING
KEY OBJECT-ORIENTED CONCEPTS
▸ Objects & Classes
▸ Methods & Messages
▸ Polymorphism & Dynamic Binding
▸ Hierarchies of classes
▸ Method overriding, self & super calls
▸ Abstract classes & methods
▸ Different kinds of inheritance
▸ Single, Multiple, Interfaces, Mixins
41
OBJECT-ORIENTED PROGRAMMING
SELF AND SUPER CALLS
Methods use:
self calls to reference the receiver object
this keyword in Java, self in Smalltalk
super to reference their implementor’s parent
Attention ! Key issue in object-oriented programming:
self = late/dynamically bound
method lookup starts again in the class of the receiver object
super = statically bound
method lookup starts in the superclass of the class of the method

containing the super expression;
not in the superclass of the receiver class
42
OBJECT-ORIENTED PROGRAMMING
SELF REFERS TO THE RECEIVER CLASS
SomeSuperclass {
void printMyself : {
self.print
}
void print : {
display("Printed in superclass. ")
}
}
SomeSubclass inherits from SomeSuperclass {
void print : {
super.print
display("Printed in subclass.”)
}
}
SubSubclass inherits from SomeSubclass {
}
test : {
s = new SubSubclass()
s.printMyself
}
}
self refers to the receiver object
receiver class is SubSubclass
self will dynamically look up
methods starting from this class
43
OBJECT-ORIENTED PROGRAMMING
METHOD OVERRIDING
Subclasses can re-implement methods that are already implemented in
superclasses
enables fine-grained reuse
clients do not have to know this (encapsulation and polymorphism)
An overridden method
can either overwrite a method with a completely new implementation
or can specialise the behaviour of the method defined in its superclass
special keyword for accessing the superclass : super
44
OBJECT-ORIENTED PROGRAMMING
EXAMPLE OF METHOD SPECIALISATION
SomeSuperclass {
void print : {
display("Printed in superclass. ")
}
}
SomeSubclass inherits from SomeSuperclass {
void print : {
super.print
display("Printed in subclass.”)
}
}
test : {
s = new SomeSubclass()
s.print
}
}
After calling test, the program prints:
Printed in superclass. Printed in subclass.
overridden method
overriding method
specialises overridden method

using super keyword
45
OBJECT-ORIENTED PROGRAMMING
SUPER IS NOT THE SUPERCLASS OF THE RECEIVER CLASS
SomeSuperclass {
void print : {
display("Printed in superclass. ")
}
}
SomeSubclass inherits from SomeSuperclass {
void print : {
super.print
display("Printed in subclass.”)
}
}
SubSubclass inherits from SomeSubclass {
}
test : {
s = new SubSubclass()
s.print
}
}
After calling test, the program prints:
Printed in superclass. Printed in subclass.
super statically refers to
this class
46
receiver class is SubSubclass
if super would refer to
the super class of the receiver
class, we would get a loop
OBJECT-ORIENTED PROGRAMMING
KEY OBJECT-ORIENTED CONCEPTS
▸ Objects & Classes
▸ Methods & Messages
▸ Polymorphism & Dynamic Binding
▸ Hierarchies of classes
▸ Method overriding, self & super calls
▸ Abstract classes & methods
▸ Different kinds of inheritance
▸ Single, Multiple, Interfaces, Mixins
47
OBJECT-ORIENTED PROGRAMMING
CONCRETE VS. ABSTRACT CLASSES
Abstract Class
Holds on to common characteristics shared
by other classes
Not expected to have instances
Concrete Class
Contains complete characterisation

of actual objects of that class
Expected to have instances
Container
colour contents
Vehicle
velocity location
LandVehicle
wheels
AirVehicle
wings
48
OBJECT-ORIENTED PROGRAMMING
ABSTRACT CLASSES AND ABSTRACT METHODS
cannot be instantiated (in Java)
but can provide some method implementations
methods of which the implementation is shared by all subclasses
methods with a default implementation to be specialised by subclasses
methods with a partial implementation to be completed by a subclass
(e.g., template method pattern)
typically have at least one abstract method
a method with an empty implementation that must be provided by each
subclass
49
OBJECT-ORIENTED PROGRAMMING
KEY OBJECT-ORIENTED CONCEPTS
▸ Objects & Classes
▸ Methods & Messages
▸ Polymorphism & Dynamic Binding
▸ Hierarchies of classes
▸ Method overriding, self & super calls
▸ Abstract classes & methods
▸ Different kinds of inheritance
▸ Single, Multiple, Interfaces, Mixins
50
OBJECT-ORIENTED PROGRAMMING
KINDS OF INHERITANCE
Different kinds of inheritance
Single: 1 superclass
Multiple: 1 or more superclasses
Interface
Mixin modules
51
OBJECT-ORIENTED PROGRAMMING
SINGLE INHERITANCE
Organises classes in tree structures
Every class has a unique superclass
There is a root class, typically called Object
52
OBJECT-ORIENTED PROGRAMMING
SINGLE INHERITANCE PROBLEMS
Classes can play several roles
Factories from which instances can be created
Units of reuse
Inheritance can play several roles
code reuse
design reuse
These roles can conflict
Multiple inheritance to the rescue… ?
53
OBJECT-ORIENTED PROGRAMMING
MULTIPLE INHERITANCE
Sometimes it is convenient to have a
class which has multiple parents
Some languages, like C++,

support multiple inheritance
Subclasses inherit instance variables
and methods from all parents
54
https://en.wikipedia.org/wiki/Multiple_inheritance
Vehicle
velocity location
FlyingCar
LandVehicle
wheels
AirVehicle
wings
OBJECT-ORIENTED PROGRAMMING
THE DIAMOND PROBLEM
A problem arises when the same methods or
variables are inherited via different paths
e.g. what version of location method to use
when called on FlyingCar?
duplicated behaviour
can be solved through manual overriding
or through linearisation
duplicated state
harder to solve
Vehicle
velocity location
LandVehicle
wheels location
AirVehicle
wings location
FlyingCar
55
OBJECT-ORIENTED PROGRAMMING
INTERFACES
Java has single inheritance
Java interfaces were introduced to provide some of the
functionality of true multiple inheritance
You can inherit from one class and from multiple interfaces

simultaneously
Interfaces are like abstract classes with no fields or method
implementations
No diamond problem since interfaces contain no data or behaviour
56
http://stackoverflow.com/questions/3556652/how-do-java-interfaces-simulate-multiple-inheritance
If Java has no multiple inheritance

then how should I do something like this?
class FoodTruck extends Truck, Kitchen {
}
foodTruck.drive();
foodTruck.cook(pizza);
OBJECT-ORIENTED PROGRAMMING
EXAMPLE OF USING INTERFACES
57
FoodTruck
Truck
drive
Kitchen
cook
http://stackoverflow.com/questions/3556652/how-do-java-interfaces-simulate-multiple-inheritance
class FoodTruck extends Truck implements KitchenInterface {
Kitchen kitchen;
public void cook(Food foodItem) {
kitchen.cook(foodItem);
}
}
foodTruck.drive();
foodTruck.cook(pizza);
OBJECT-ORIENTED PROGRAMMING
EXAMPLE OF USING INTERFACES
58
FoodTruck
cook
Truck
drive
KitchenInterface
cook
http://stackoverflow.com/questions/3556652/how-do-java-interfaces-simulate-multiple-inheritance
interface

inheritance
class

inheritance
interfaceclass
Kitchen
cook
OBJECT-ORIENTED PROGRAMMING
MIXINS
Factoring out the increment when subclassing
Mixins can be seen as the “increment” that needs to be applied to a class
Mixin composition is an operation that applies a mixin to a class to produce a
more specialised class
Typically, mixin composition is linearised
this can cause problems:
composition order important
introducing extra mixin can change behaviour
Example: mixin modules in Ruby
59
OBJECT-ORIENTED PROGRAMMING
CONCLUSION
OO promotes maintainability by viewing programs as collections of loosely connected
objects
Each object is responsible for specific tasks
It is through the interaction of objects that computation proceeds
Objects can be defined and manipulated in terms of the messages they understand
and ignoring the implementation details
OO promotes the development of reusable components
By reducing the interdependency among individual software components
Such components can be created and tested as independent units in isolation from the
rest of the software system
Reusable software components permit to treat problems at a higher level of abstraction
60
OBJECT-ORIENTED PROGRAMMING
ABSTRACTION MECHANISMS (REVISITED)
Encapsulation
objects contain their own data as well as the methods that work on that data
Information hiding
clients of an object know only the set of messages it can receive
implementation details of how it processes these messages remain hidden to external clients
Polymorphism
cleaner and more maintainable code by delegating responsibilities and implementation choices
to the objects
Code sharing
classes enable sharing behaviour among objects
class hierarchies and inheritance enable reuse of class definitions
61
LINGI2252 – 3. SOFTWARE REUSE
LEARNING OBJECTIVES
▸ definitions of reusability, software reuse and reusable component
▸ how object-oriented programming promotes modularity, maintainability and
reuse
▸ encapsulation, information hiding, polymorphism and code sharing
▸ key object-oriented concepts: object, classes, methods, messages, inheritance
▸ polymorphism and dynamic binding
▸ method overriding, self and super calls
▸ abstract classes and methods
▸ different kinds of inheritance: single, multiple, interfaces, mixins
LINGI2252 – 3. SOFTWARE REUSE
POSSIBLE QUESTIONS
▸ Define and illustrate, in your own words, the notions of software reuse, reusability and reusable
components.
▸ Give two economic and two intellectual justifications for software reuse.
▸ Give (and explain) at least 3 different software reuse techniques seen throughout the course.
▸ How and why does object-oriented programming promote modularity and maintainability?
▸ Explain the object-oriented techniques of encapsulation, information hiding, polymorphism and code
sharing and their link with software reusability.
▸ Explain, using a concrete example, what polymorphism and dynamic binding is, and how it can lead to
more maintainable code.
▸ Explain on a concrete example the concepts of method overriding, self and super calls.
▸ How can abstract classes and methods improve reusability?
▸ Explain, using a concrete example, how a multiple inheritance problem could be modelled in terms of
single inheritance on classes and interfaces in Java.

More Related Content

What's hot

Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML DiagramsManish Kumar
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design patternMindfire Solutions
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and DesignHaitham El-Ghareeb
 
Android graphics
Android graphicsAndroid graphics
Android graphicsKrazy Koder
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software EngineeringManish Kumar
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patternsAmit Kabra
 
Uml with detail
Uml with detailUml with detail
Uml with detailHamza Khan
 
Software Process Models
Software Process ModelsSoftware Process Models
Software Process ModelsHassan A-j
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJBPeter R. Egli
 
Object Oriented Design Concept
Object Oriented Design ConceptObject Oriented Design Concept
Object Oriented Design ConceptSharath g
 
Introduction to Software Project Management
Introduction to Software Project ManagementIntroduction to Software Project Management
Introduction to Software Project ManagementReetesh Gupta
 
Design Concept software engineering
Design Concept software engineeringDesign Concept software engineering
Design Concept software engineeringDarshit Metaliya
 
Unit 2(advanced class modeling & state diagram)
Unit  2(advanced class modeling & state diagram)Unit  2(advanced class modeling & state diagram)
Unit 2(advanced class modeling & state diagram)Manoj Reddy
 
UML diagrams and symbols
UML diagrams and symbolsUML diagrams and symbols
UML diagrams and symbolsKumar
 
Object oriented and function oriented design
Object oriented and function oriented designObject oriented and function oriented design
Object oriented and function oriented designNaveen Sagayaselvaraj
 

What's hot (20)

Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
 
CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3
 
Grasp
GraspGrasp
Grasp
 
Android graphics
Android graphicsAndroid graphics
Android graphics
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software Engineering
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
 
Uml with detail
Uml with detailUml with detail
Uml with detail
 
Software Process Models
Software Process ModelsSoftware Process Models
Software Process Models
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
 
Object Oriented Design Concept
Object Oriented Design ConceptObject Oriented Design Concept
Object Oriented Design Concept
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
 
Introduction to Software Project Management
Introduction to Software Project ManagementIntroduction to Software Project Management
Introduction to Software Project Management
 
Design Concept software engineering
Design Concept software engineeringDesign Concept software engineering
Design Concept software engineering
 
Unit 2(advanced class modeling & state diagram)
Unit  2(advanced class modeling & state diagram)Unit  2(advanced class modeling & state diagram)
Unit 2(advanced class modeling & state diagram)
 
UML diagrams and symbols
UML diagrams and symbolsUML diagrams and symbols
UML diagrams and symbols
 
Object oriented and function oriented design
Object oriented and function oriented designObject oriented and function oriented design
Object oriented and function oriented design
 

Viewers also liked

Gpu with cuda architecture
Gpu with cuda architectureGpu with cuda architecture
Gpu with cuda architectureDhaval Kaneria
 
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMINGFINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMINGAmira Dolce Farhana
 
Extreme programming
Extreme programmingExtreme programming
Extreme programmingMr SMAK
 
extreme Programming
extreme Programmingextreme Programming
extreme ProgrammingBilal Shah
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming ConceptsKwangshin Oh
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingMoutaz Haddara
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languagesVarun Garg
 
Software reuse ppt.
Software reuse ppt.Software reuse ppt.
Software reuse ppt.Sumit Biswas
 

Viewers also liked (11)

OOP design patterns
OOP design patternsOOP design patterns
OOP design patterns
 
Importance Of Software Development
Importance Of Software DevelopmentImportance Of Software Development
Importance Of Software Development
 
Gpu with cuda architecture
Gpu with cuda architectureGpu with cuda architecture
Gpu with cuda architecture
 
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMINGFINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
 
System development methodologies
System development methodologiesSystem development methodologies
System development methodologies
 
Extreme programming
Extreme programmingExtreme programming
Extreme programming
 
extreme Programming
extreme Programmingextreme Programming
extreme Programming
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming Concepts
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
Software reuse ppt.
Software reuse ppt.Software reuse ppt.
Software reuse ppt.
 

Similar to Software Reuse and Object-Oriented Programming

Software engineering: design for reuse
Software engineering: design for reuseSoftware engineering: design for reuse
Software engineering: design for reuseMarco Brambilla
 
Object Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperObject Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperLee Greffin
 
Software development effort reduction with Co-op
Software development effort reduction with Co-opSoftware development effort reduction with Co-op
Software development effort reduction with Co-oplbergmans
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principlesdeonpmeyer
 
Object-Oriented Application Frameworks
Object-Oriented Application FrameworksObject-Oriented Application Frameworks
Object-Oriented Application Frameworkskim.mens
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfHouseMusica
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsShanmuganathan C
 
B vb script11
B vb script11B vb script11
B vb script11oakhrd
 
Software_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptxSoftware_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptxArifaMehreen1
 
Reengineering and Reuse of Legacy Software
Reengineering and Reuse of Legacy SoftwareReengineering and Reuse of Legacy Software
Reengineering and Reuse of Legacy SoftwareTeodoro Cipresso
 
OOP-Advanced_Programming.pptx
OOP-Advanced_Programming.pptxOOP-Advanced_Programming.pptx
OOP-Advanced_Programming.pptxMohamed Essam
 
Cocoa encyclopedia
Cocoa encyclopediaCocoa encyclopedia
Cocoa encyclopediaAlex Ali
 
DOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cDOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cfloraaluoch3
 
Assignment 1 SYD601 2012 rick_danby completed with audio
Assignment 1 SYD601 2012 rick_danby completed with audioAssignment 1 SYD601 2012 rick_danby completed with audio
Assignment 1 SYD601 2012 rick_danby completed with audioRickNZ
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basicsvamshimahi
 

Similar to Software Reuse and Object-Oriented Programming (20)

Software engineering: design for reuse
Software engineering: design for reuseSoftware engineering: design for reuse
Software engineering: design for reuse
 
Object Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperObject Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft Developer
 
General oop concept
General oop conceptGeneral oop concept
General oop concept
 
Software development effort reduction with Co-op
Software development effort reduction with Co-opSoftware development effort reduction with Co-op
Software development effort reduction with Co-op
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Object-Oriented Application Frameworks
Object-Oriented Application FrameworksObject-Oriented Application Frameworks
Object-Oriented Application Frameworks
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdf
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objects
 
L03 Software Design
L03 Software DesignL03 Software Design
L03 Software Design
 
B vb script11
B vb script11B vb script11
B vb script11
 
Software_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptxSoftware_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptx
 
Reengineering and Reuse of Legacy Software
Reengineering and Reuse of Legacy SoftwareReengineering and Reuse of Legacy Software
Reengineering and Reuse of Legacy Software
 
Mcs024
Mcs024Mcs024
Mcs024
 
OOP-Advanced_Programming.pptx
OOP-Advanced_Programming.pptxOOP-Advanced_Programming.pptx
OOP-Advanced_Programming.pptx
 
Objective-C
Objective-CObjective-C
Objective-C
 
Cocoa encyclopedia
Cocoa encyclopediaCocoa encyclopedia
Cocoa encyclopedia
 
DOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cDOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in c
 
Assignment 1 SYD601 2012 rick_danby completed with audio
Assignment 1 SYD601 2012 rick_danby completed with audioAssignment 1 SYD601 2012 rick_danby completed with audio
Assignment 1 SYD601 2012 rick_danby completed with audio
 
Elaboration
ElaborationElaboration
Elaboration
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basics
 

More from kim.mens

Software Maintenance and Evolution
Software Maintenance and EvolutionSoftware Maintenance and Evolution
Software Maintenance and Evolutionkim.mens
 
Context-Oriented Programming
Context-Oriented ProgrammingContext-Oriented Programming
Context-Oriented Programmingkim.mens
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smellskim.mens
 
Object-Oriented Design Heuristics
Object-Oriented Design HeuristicsObject-Oriented Design Heuristics
Object-Oriented Design Heuristicskim.mens
 
Software Patterns
Software PatternsSoftware Patterns
Software Patternskim.mens
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoringkim.mens
 
Domain Modelling
Domain ModellingDomain Modelling
Domain Modellingkim.mens
 
Towards a Context-Oriented Software Implementation Framework
Towards a Context-Oriented Software Implementation FrameworkTowards a Context-Oriented Software Implementation Framework
Towards a Context-Oriented Software Implementation Frameworkkim.mens
 
Towards a Taxonomy of Context-Aware Software Variabilty Approaches
Towards a Taxonomy of Context-Aware Software Variabilty ApproachesTowards a Taxonomy of Context-Aware Software Variabilty Approaches
Towards a Taxonomy of Context-Aware Software Variabilty Approacheskim.mens
 
Breaking the Walls: A Unified Vision on Context-Oriented Software Engineering
Breaking the Walls: A Unified Vision on Context-Oriented Software EngineeringBreaking the Walls: A Unified Vision on Context-Oriented Software Engineering
Breaking the Walls: A Unified Vision on Context-Oriented Software Engineeringkim.mens
 
Context-oriented programming
Context-oriented programmingContext-oriented programming
Context-oriented programmingkim.mens
 
Basics of reflection
Basics of reflectionBasics of reflection
Basics of reflectionkim.mens
 
Advanced Reflection in Java
Advanced Reflection in JavaAdvanced Reflection in Java
Advanced Reflection in Javakim.mens
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in javakim.mens
 
Reflection in Ruby
Reflection in RubyReflection in Ruby
Reflection in Rubykim.mens
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Rubykim.mens
 
Introduction to Smalltalk
Introduction to SmalltalkIntroduction to Smalltalk
Introduction to Smalltalkkim.mens
 
A gentle introduction to reflection
A gentle introduction to reflectionA gentle introduction to reflection
A gentle introduction to reflectionkim.mens
 
Managing the Evolution of Information Systems with Intensional Views and Rela...
Managing the Evolution of Information Systems with Intensional Views and Rela...Managing the Evolution of Information Systems with Intensional Views and Rela...
Managing the Evolution of Information Systems with Intensional Views and Rela...kim.mens
 
Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)
Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)
Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)kim.mens
 

More from kim.mens (20)

Software Maintenance and Evolution
Software Maintenance and EvolutionSoftware Maintenance and Evolution
Software Maintenance and Evolution
 
Context-Oriented Programming
Context-Oriented ProgrammingContext-Oriented Programming
Context-Oriented Programming
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smells
 
Object-Oriented Design Heuristics
Object-Oriented Design HeuristicsObject-Oriented Design Heuristics
Object-Oriented Design Heuristics
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Domain Modelling
Domain ModellingDomain Modelling
Domain Modelling
 
Towards a Context-Oriented Software Implementation Framework
Towards a Context-Oriented Software Implementation FrameworkTowards a Context-Oriented Software Implementation Framework
Towards a Context-Oriented Software Implementation Framework
 
Towards a Taxonomy of Context-Aware Software Variabilty Approaches
Towards a Taxonomy of Context-Aware Software Variabilty ApproachesTowards a Taxonomy of Context-Aware Software Variabilty Approaches
Towards a Taxonomy of Context-Aware Software Variabilty Approaches
 
Breaking the Walls: A Unified Vision on Context-Oriented Software Engineering
Breaking the Walls: A Unified Vision on Context-Oriented Software EngineeringBreaking the Walls: A Unified Vision on Context-Oriented Software Engineering
Breaking the Walls: A Unified Vision on Context-Oriented Software Engineering
 
Context-oriented programming
Context-oriented programmingContext-oriented programming
Context-oriented programming
 
Basics of reflection
Basics of reflectionBasics of reflection
Basics of reflection
 
Advanced Reflection in Java
Advanced Reflection in JavaAdvanced Reflection in Java
Advanced Reflection in Java
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in java
 
Reflection in Ruby
Reflection in RubyReflection in Ruby
Reflection in Ruby
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Introduction to Smalltalk
Introduction to SmalltalkIntroduction to Smalltalk
Introduction to Smalltalk
 
A gentle introduction to reflection
A gentle introduction to reflectionA gentle introduction to reflection
A gentle introduction to reflection
 
Managing the Evolution of Information Systems with Intensional Views and Rela...
Managing the Evolution of Information Systems with Intensional Views and Rela...Managing the Evolution of Information Systems with Intensional Views and Rela...
Managing the Evolution of Information Systems with Intensional Views and Rela...
 
Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)
Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)
Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)
 

Recently uploaded

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 

Recently uploaded (20)

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

Software Reuse and Object-Oriented Programming

  • 1. SOFTWARE REUSE
 & OBJECT-ORIENTED PROGRAMMING LINGI2252 – PROF. KIM MENS * These slides are part of the course LINGI2252 “Software Maintenance and Evolution”, given by Prof. Kim Mens at UCL, Belgium *
  • 2. A. SOFTWARE REUSE LINGI2252 – PROF. KIM MENS
  • 3. SOFTWARE REUSE REUSABILITY [DEFINITION] Reusability is a general engineering principle whose importance derives from the desire to avoid duplication and to capture commonality in undertaking classes of inherently similar tasks. Source: Peter Wegner, "Capital-Intensive Software Technology", in Chapter 3 of Software Reusability, Volume I : Concepts and Models, ACM Press, 1989. Software reusability is the degree to which a software module or other work product can be used in more than one software system. Reusable: pertaining to a software module or other work product that can be used in more than one computer program or software system. 3
  • 4. SOFTWARE REUSE SOFTWARE REUSE [DEFINITION] Software reuse The reapplication of a variety of kinds of knowledge about one system to another in order to reduce the effort of developing or maintaining that other system. This “reused knowledge” includes artefacts such as domain knowledge, development experience, requirements, architectural components, design artefacts, code, documentation, and so forth. Source: Software Reusability, Volume I : Concepts and Models, Eds. Biggerstaff & Perlis, ACM Press, 1989. 4
  • 5. SOFTWARE REUSE REUSABLE COMPONENT [DEFINITION] Software reuse The process of implementing new software systems using existing software information. Reusable component A software component designed and implemented for the specific purpose of being reused. Component can be requirement, architecture, design, code, test data, etc. Source: Kang & al., Feature-Oriented Domain Analysis (FODA): Feasibility Study, Technical Report CMU/SEI-90-TR-21, 1990. 5
  • 6. SOFTWARE REUSE SOFTWARE REUSE [EXAMPLE] Using functions available in some library. E.g., C libraries are collections of precompiled functions that have been written to be reused by other programmers. Reusing classes from another object-oriented program. Adapting the modules of a software system with a very similar functionality (member of a same “family”). Reusing the architecture or design of a software system when porting it to a new language. 6
  • 7. SOFTWARE REUSE WHY REUSE? Economic justification: more productive by avoiding double work better quality by reusing good solutions Intellectual justification: stand on each other's shoulders don't reinvent or reimplement old stuff focus on what's new and relevant 7
  • 8. SOFTWARE REUSE SOME REUSE TECHNIQUES Programming abstractions and mechanisms procedural and data abstraction
 encapsulation and information hiding
 code sharing and reuse mechanisms Design patterns Software architecture Software libraries & application frameworks Generative programming & model-driven development 8
  • 10. OBJECT-ORIENTED PROGRAMMING OBJECT-ORIENTED PROGRAMMING PROMOTES MODULARITY AND REUSE It is often “claimed” that object-oriented programming is a better way of writing more modular programs leverages code sharing and design reuse minimises maintenance costs Thanks to its abstraction mechanisms 10
  • 11. OBJECT-ORIENTED PROGRAMMING ABSTRACTION MECHANISMS Encapsulation keep data and operations that act on this data together Information hiding isolate and hide design and implementation choices Polymorphism allow for different implementations of a same design to co-exist Code sharing capture and exploit similarities in data and behaviour
 (through inheritance) 11
  • 12. OBJECT-ORIENTED PROGRAMMING KEY OBJECT-ORIENTED CONCEPTS Objects & Classes Methods & Messages Polymorphism & Dynamic Binding Hierarchies of classes Method overriding, self & super calls Abstract classes & methods Different kinds of inheritance Single, Multiple, Interfaces, Mixins 12 DISCLAIMER ALTHOUGH WHAT FOLLOWS MAY
 SEEM LIKE A CRASH COURSE IN OO
 OUR FOCUS WILL LIE ON THE MECHANISMS IT PROVIDES FOR ACHIEVING MODULARITY, MAINTAINABILITY, SHARING AND REUSE
  • 13. OBJECT-ORIENTED PROGRAMMING TWO MAIN PRINCIPLES OF OBJECT-ORIENTED PROGRAMMING Everything is an object Objects respond only to messages 13
  • 14. OBJECT-ORIENTED PROGRAMMING SMALLTALK’S INFLUENCE Smalltalk is a pure object-oriented language Was a source of inspiration to many OO languages Ruby is heavily inspired on Smalltalk Objective-C and Swift heavily inspired on Smalltalk Java is heavily influenced by Smalltalk 14 DISCLAIMER THIS SESSION MAY CONTAIN TRACES OF SMALLTALK CODE
 (FOR DIDACTIC PURPOSES)
  • 15. OBJECT-ORIENTED PROGRAMMING KEY OBJECT-ORIENTED CONCEPTS Objects & Classes Methods & Messages Polymorphism & Dynamic Binding Hierarchies of classes Method overriding, self & super calls Abstract classes & methods Different kinds of inheritance Single, Multiple, Interfaces, Mixins 15
  • 16. OBJECT-ORIENTED PROGRAMMING OBJECTS ENCAPSULATE DATA Every object has its own data or state Values stored in the objects (but variables declared in classes) Data is encapsulated Protected from the outside world Only accessible through messages aPoint x 5 y 10 16 circumference aCircle center • radius 2
  • 17. OBJECT-ORIENTED PROGRAMMING CLASSES ENCAPSULATE BEHAVIOUR Classes declare the state of objects
 (but objects contain the actual values) define the behaviour of objects method implementations shared among all objects of a class can manipulate the state directly Behaviour is encapsulated invoked by sending message to an object Circle center (Point) radius (Number) surface π.radius2 circumference 2.π.radius 17
  • 18. OBJECT-ORIENTED PROGRAMMING CLASSES ARE FACTORIES OF OBJECTS A class is a “factory” for producing objects of the same type e.g., with a Circle class you can create many circle objects Every object is an instance of the class from which it was created A class is a blueprint for objects that share behaviour and state All objects of a class behave in a similar fashion in response to a same message Enables reuse of behaviour 18
  • 19. OBJECT-ORIENTED PROGRAMMING CLASSES & OBJECTS PROMOTE MODULARITY Through encapsulation of both behaviour and state grouping behaviour with the data it acts upon facilitates modularity, code reuse and maintenance 19
  • 20. OBJECT-ORIENTED PROGRAMMING CLASSES & OBJECTS PROMOTE REUSE Classes are fine-grained reusable components that enable sharing and reuse of structure and behaviour even across applications for example via application frameworks or reusable class hierarchies 20
  • 21. OBJECT-ORIENTED PROGRAMMING KEY OBJECT-ORIENTED CONCEPTS ▸ Objects & Classes ▸ Methods & Messages ▸ Polymorphism & Dynamic Binding ▸ Hierarchies of classes ▸ Method overriding, self & super calls ▸ Abstract classes & methods ▸ Different kinds of inheritance ▸ Single, Multiple, Interfaces, Mixins 21
  • 22. OBJECT-ORIENTED PROGRAMMING METHODS & MESSAGES (RECAP) Objects (not functions or procedures) are the main building blocks of OO Objects communicate through message passing Objects exhibit behaviour in response to messages sent to them The actual behaviour is implemented in methods Methods specify what behaviour to perform on objects Methods can manipulate the objects’ internal state 22
  • 23. OBJECT-ORIENTED PROGRAMMING POLYMORPHIC METHODS A same message can be sent to objects of different classes aCircle.surface aRectangle.surface Different objects can react differently to the same message different classes can provide different implementations
 for methods with the same name Circle > surface = π.radius 2
 Rectangle > surface = (bottom-top).(right-left) Responsibility of how to handle the message is decided by the object
 (depending on the class to which it belongs) This is called “polymorphism” 23
  • 24. OBJECT-ORIENTED PROGRAMMING ADVANTAGES OF POLYMORPHISM Cleaner, more maintainable code Less ≠ method names Less need for conditionals More implementation freedom Each class can decide how best to implement a method Locality Every object/class is responsible for its own actions Easy to change the implementation by another one 24
  • 25. OBJECT-ORIENTED PROGRAMMING EXAMPLE OF POLYMORPHISM Procedural style vs. object-oriented style Example: Write some code that calculates the sum of the surfaces of a collection of different shape objects surface(collection) = Σshape∈collection surface(shape) 25
  • 26. OBJECT-ORIENTED PROGRAMMING EXAMPLE OF POLYMORPHISM (PSEUDOCODE) Procedural style (no polymorphism) circleSurface(c) = π.radius(c)2
 rectangleSurface(r) = (bottom(r) - top(r)) * (right(r) - left(r))
 surface(collection) : Real total = 0 ∀ shape ∈ collection : if ( shape == Circle ) then total = total + circleSurface(shape) else if ( shape == Rectangle ) then total = total + rectangleSurface(shape) return total 26
  • 27. OBJECT-ORIENTED PROGRAMMING EXAMPLE OF POLYMORPHISM (PSEUDOCODE) OO style (using polymorphism) Circle { Point center ; Real radius ; Real surface() : { π.radius2 } } Rectangle { Real bottom, top, right, left; Real surface() : { (bottom-top)*(right-left) } } Real surface(collection) : { total = 0 ∀ shape ∈ collection : total = total + shape.surface() return total
 } 27
  • 28. OBJECT-ORIENTED PROGRAMMING EXAMPLE OF POLYMORPHISM (PSEUDOCODE) OO style (using polymorphism) 
 Real surface(collection) : { total = 0 ∀ shape ∈ collection : total = total + shape.surface() return total
 }
 Advantages: Adding a new shape does not require to change the existing implementation No need to know the kind of objects it manipulates as long as they all share a common interface 28
  • 29. OBJECT-ORIENTED PROGRAMMING LATE BINDING When sending a message, the actual receiver of a message is not necessarily known until run-time Mapping of messages to methods is deferred until run-time depending on which object actually received the message we call this late binding or dynamic binding Most traditional languages do this at compile time (static binding) Smalltalk uses late binding 29 surface aCircle aRectangle aTriangle
  • 30. OBJECT-ORIENTED PROGRAMMING EXAMPLE OF LATE BINDING (PSEUDOCODE) Circle { Point center ; Real radius ; Real surface() : { π.radius 2 } } Rectangle { Real bottom, top, right, left; Real surface() : { (bottom-top)*(right-left) } } test() : { shape = new Circle(new Point(0,0), 2); print(shape.surface()); shape = new Rectangle(10,10,30,50); print(shape.surface()) } polymorphic methods late bound messages
  • 31. OBJECT-ORIENTED PROGRAMMING STATIC VS. DYNAMIC BINDING IN JAVA Smalltalk uses dynamic binding (a.k.a. late binding) For Java it depends Binding of overridden methods happens at runtime (dynamic) Binding for overloaded methods at compile time (static) Binding of private, static and final methods at compile time (static) since these methods cannot be overridden. Sources: http://beginnersbook.com/2013/04/java-static-dynamic-binding/ http://stackoverflow.com/questions/19017258/static-vs-dynamic-binding-in-java 31
  • 32. OBJECT-ORIENTED PROGRAMMING LATE BINDING EXAMPLE (JAVA) Source: http://stackoverflow.com/questions/19017258/static-vs-dynamic-binding-in-java Apart from syntactic differences and the lack of type declarations in Smalltalk, this example could be recreated nearly “as is” in Smalltalk. In fact for Smalltalk you could even create an example that doesn’t require inheritance.
  • 33. OBJECT-ORIENTED PROGRAMMING LATE BINDING EXAMPLE IN JAVA The method call vehicle.start()
 is dynamically bound to the overridden Car > start() method Because even though vehicle is typed as being of class Vehicle, it is determined at runtime that it contains an object of type Car and because the method start() is overridden
  • 34. OBJECT-ORIENTED PROGRAMMING STATIC BINDING EXAMPLE IN JAVA 34 Source: http://stackoverflow.com/questions/19017258/static-vs-dynamic-binding-in-java
  • 35. OBJECT-ORIENTED PROGRAMMING STATIC BINDING EXAMPLE IN JAVA The method call et.sort(c)
 is statically determined by
 the compiler to refer to
 the sort(Collection) method Even though c is an object of type HashSet and the sort(HashSet) method is more specific Because c is statically
 determined to have type Collection and the method sort is overloaded, not overridden 35 This example cannot be recreated in Smalltalk since Smalltalk has no method overloading. (Nor does it have final methods or private methods.)
  • 36. OBJECT-ORIENTED PROGRAMMING CLASSES & OBJECTS PROMOTE MODULARITY Through information hiding restricted access to objects through a well-defined interface users of an object only know the set of messages it will accept they do not know how the actions performed in response to a message are carried out This is the responsibility of the receiving object (through polymorphism) improves modularity by hiding implementation details How the data is represented internally How the behaviour is implemented in terms of that data 36
  • 37. OBJECT-ORIENTED PROGRAMMING KEY OBJECT-ORIENTED CONCEPTS ▸ Objects & Classes ▸ Methods & Messages ▸ Polymorphism & Dynamic Binding ▸ Hierarchies of classes ▸ Method overriding, self & super calls ▸ Abstract classes & methods ▸ Different kinds of inheritance ▸ Single, Multiple, Interfaces, Mixins 37
  • 38. OBJECT-ORIENTED PROGRAMMING HIERARCHIES OF CLASSES Shape colour (Colour) Rectangle bottom top left right surface height*width circumference 2.height+2.width Circle center radius surface π.radius2 circumference 2.π.radius 38
  • 39. OBJECT-ORIENTED PROGRAMMING HIERARCHIES OF CLASSES Classes are typically organised into hierarchical structures Information (data/behaviour) associated with classes higher in the hierarchy is automatically accessible to classes lower in the hierarchy Each subclass specialises the definition of its ancestors subclasses can use ancestor’s behaviour and state subclasses can add new state and behaviour subclasses can specialise ancestor behaviour subclasses can override ancestor’s behaviour 39
  • 40. OBJECT-ORIENTED PROGRAMMING HIERARCHIES OF CLASSES Inheritance is a powerful incremental reuse mechanism Often you don’t want to rewrite everything; you just want some small changes to what exists Classes are the units of reuse Inheritance is the reuse mechanism e.g., extends keyword in Java :
 class Automobile extends LandVehicle Class hierarchies are ideal for sharing declarations and implementation among classes Object’s state and behavioural description is broken into pieces and distributed along specialisation paths Promotes encapsulation, modularity, and reusability Container colour contents Vehicle velocity location LandVehicle wheels Automobile brand 40
  • 41. OBJECT-ORIENTED PROGRAMMING KEY OBJECT-ORIENTED CONCEPTS ▸ Objects & Classes ▸ Methods & Messages ▸ Polymorphism & Dynamic Binding ▸ Hierarchies of classes ▸ Method overriding, self & super calls ▸ Abstract classes & methods ▸ Different kinds of inheritance ▸ Single, Multiple, Interfaces, Mixins 41
  • 42. OBJECT-ORIENTED PROGRAMMING SELF AND SUPER CALLS Methods use: self calls to reference the receiver object this keyword in Java, self in Smalltalk super to reference their implementor’s parent Attention ! Key issue in object-oriented programming: self = late/dynamically bound method lookup starts again in the class of the receiver object super = statically bound method lookup starts in the superclass of the class of the method
 containing the super expression; not in the superclass of the receiver class 42
  • 43. OBJECT-ORIENTED PROGRAMMING SELF REFERS TO THE RECEIVER CLASS SomeSuperclass { void printMyself : { self.print } void print : { display("Printed in superclass. ") } } SomeSubclass inherits from SomeSuperclass { void print : { super.print display("Printed in subclass.”) } } SubSubclass inherits from SomeSubclass { } test : { s = new SubSubclass() s.printMyself } } self refers to the receiver object receiver class is SubSubclass self will dynamically look up methods starting from this class 43
  • 44. OBJECT-ORIENTED PROGRAMMING METHOD OVERRIDING Subclasses can re-implement methods that are already implemented in superclasses enables fine-grained reuse clients do not have to know this (encapsulation and polymorphism) An overridden method can either overwrite a method with a completely new implementation or can specialise the behaviour of the method defined in its superclass special keyword for accessing the superclass : super 44
  • 45. OBJECT-ORIENTED PROGRAMMING EXAMPLE OF METHOD SPECIALISATION SomeSuperclass { void print : { display("Printed in superclass. ") } } SomeSubclass inherits from SomeSuperclass { void print : { super.print display("Printed in subclass.”) } } test : { s = new SomeSubclass() s.print } } After calling test, the program prints: Printed in superclass. Printed in subclass. overridden method overriding method specialises overridden method
 using super keyword 45
  • 46. OBJECT-ORIENTED PROGRAMMING SUPER IS NOT THE SUPERCLASS OF THE RECEIVER CLASS SomeSuperclass { void print : { display("Printed in superclass. ") } } SomeSubclass inherits from SomeSuperclass { void print : { super.print display("Printed in subclass.”) } } SubSubclass inherits from SomeSubclass { } test : { s = new SubSubclass() s.print } } After calling test, the program prints: Printed in superclass. Printed in subclass. super statically refers to this class 46 receiver class is SubSubclass if super would refer to the super class of the receiver class, we would get a loop
  • 47. OBJECT-ORIENTED PROGRAMMING KEY OBJECT-ORIENTED CONCEPTS ▸ Objects & Classes ▸ Methods & Messages ▸ Polymorphism & Dynamic Binding ▸ Hierarchies of classes ▸ Method overriding, self & super calls ▸ Abstract classes & methods ▸ Different kinds of inheritance ▸ Single, Multiple, Interfaces, Mixins 47
  • 48. OBJECT-ORIENTED PROGRAMMING CONCRETE VS. ABSTRACT CLASSES Abstract Class Holds on to common characteristics shared by other classes Not expected to have instances Concrete Class Contains complete characterisation
 of actual objects of that class Expected to have instances Container colour contents Vehicle velocity location LandVehicle wheels AirVehicle wings 48
  • 49. OBJECT-ORIENTED PROGRAMMING ABSTRACT CLASSES AND ABSTRACT METHODS cannot be instantiated (in Java) but can provide some method implementations methods of which the implementation is shared by all subclasses methods with a default implementation to be specialised by subclasses methods with a partial implementation to be completed by a subclass (e.g., template method pattern) typically have at least one abstract method a method with an empty implementation that must be provided by each subclass 49
  • 50. OBJECT-ORIENTED PROGRAMMING KEY OBJECT-ORIENTED CONCEPTS ▸ Objects & Classes ▸ Methods & Messages ▸ Polymorphism & Dynamic Binding ▸ Hierarchies of classes ▸ Method overriding, self & super calls ▸ Abstract classes & methods ▸ Different kinds of inheritance ▸ Single, Multiple, Interfaces, Mixins 50
  • 51. OBJECT-ORIENTED PROGRAMMING KINDS OF INHERITANCE Different kinds of inheritance Single: 1 superclass Multiple: 1 or more superclasses Interface Mixin modules 51
  • 52. OBJECT-ORIENTED PROGRAMMING SINGLE INHERITANCE Organises classes in tree structures Every class has a unique superclass There is a root class, typically called Object 52
  • 53. OBJECT-ORIENTED PROGRAMMING SINGLE INHERITANCE PROBLEMS Classes can play several roles Factories from which instances can be created Units of reuse Inheritance can play several roles code reuse design reuse These roles can conflict Multiple inheritance to the rescue… ? 53
  • 54. OBJECT-ORIENTED PROGRAMMING MULTIPLE INHERITANCE Sometimes it is convenient to have a class which has multiple parents Some languages, like C++,
 support multiple inheritance Subclasses inherit instance variables and methods from all parents 54 https://en.wikipedia.org/wiki/Multiple_inheritance Vehicle velocity location FlyingCar LandVehicle wheels AirVehicle wings
  • 55. OBJECT-ORIENTED PROGRAMMING THE DIAMOND PROBLEM A problem arises when the same methods or variables are inherited via different paths e.g. what version of location method to use when called on FlyingCar? duplicated behaviour can be solved through manual overriding or through linearisation duplicated state harder to solve Vehicle velocity location LandVehicle wheels location AirVehicle wings location FlyingCar 55
  • 56. OBJECT-ORIENTED PROGRAMMING INTERFACES Java has single inheritance Java interfaces were introduced to provide some of the functionality of true multiple inheritance You can inherit from one class and from multiple interfaces
 simultaneously Interfaces are like abstract classes with no fields or method implementations No diamond problem since interfaces contain no data or behaviour 56 http://stackoverflow.com/questions/3556652/how-do-java-interfaces-simulate-multiple-inheritance
  • 57. If Java has no multiple inheritance
 then how should I do something like this? class FoodTruck extends Truck, Kitchen { } foodTruck.drive(); foodTruck.cook(pizza); OBJECT-ORIENTED PROGRAMMING EXAMPLE OF USING INTERFACES 57 FoodTruck Truck drive Kitchen cook http://stackoverflow.com/questions/3556652/how-do-java-interfaces-simulate-multiple-inheritance
  • 58. class FoodTruck extends Truck implements KitchenInterface { Kitchen kitchen; public void cook(Food foodItem) { kitchen.cook(foodItem); } } foodTruck.drive(); foodTruck.cook(pizza); OBJECT-ORIENTED PROGRAMMING EXAMPLE OF USING INTERFACES 58 FoodTruck cook Truck drive KitchenInterface cook http://stackoverflow.com/questions/3556652/how-do-java-interfaces-simulate-multiple-inheritance interface
 inheritance class
 inheritance interfaceclass Kitchen cook
  • 59. OBJECT-ORIENTED PROGRAMMING MIXINS Factoring out the increment when subclassing Mixins can be seen as the “increment” that needs to be applied to a class Mixin composition is an operation that applies a mixin to a class to produce a more specialised class Typically, mixin composition is linearised this can cause problems: composition order important introducing extra mixin can change behaviour Example: mixin modules in Ruby 59
  • 60. OBJECT-ORIENTED PROGRAMMING CONCLUSION OO promotes maintainability by viewing programs as collections of loosely connected objects Each object is responsible for specific tasks It is through the interaction of objects that computation proceeds Objects can be defined and manipulated in terms of the messages they understand and ignoring the implementation details OO promotes the development of reusable components By reducing the interdependency among individual software components Such components can be created and tested as independent units in isolation from the rest of the software system Reusable software components permit to treat problems at a higher level of abstraction 60
  • 61. OBJECT-ORIENTED PROGRAMMING ABSTRACTION MECHANISMS (REVISITED) Encapsulation objects contain their own data as well as the methods that work on that data Information hiding clients of an object know only the set of messages it can receive implementation details of how it processes these messages remain hidden to external clients Polymorphism cleaner and more maintainable code by delegating responsibilities and implementation choices to the objects Code sharing classes enable sharing behaviour among objects class hierarchies and inheritance enable reuse of class definitions 61
  • 62.
  • 63. LINGI2252 – 3. SOFTWARE REUSE LEARNING OBJECTIVES ▸ definitions of reusability, software reuse and reusable component ▸ how object-oriented programming promotes modularity, maintainability and reuse ▸ encapsulation, information hiding, polymorphism and code sharing ▸ key object-oriented concepts: object, classes, methods, messages, inheritance ▸ polymorphism and dynamic binding ▸ method overriding, self and super calls ▸ abstract classes and methods ▸ different kinds of inheritance: single, multiple, interfaces, mixins
  • 64. LINGI2252 – 3. SOFTWARE REUSE POSSIBLE QUESTIONS ▸ Define and illustrate, in your own words, the notions of software reuse, reusability and reusable components. ▸ Give two economic and two intellectual justifications for software reuse. ▸ Give (and explain) at least 3 different software reuse techniques seen throughout the course. ▸ How and why does object-oriented programming promote modularity and maintainability? ▸ Explain the object-oriented techniques of encapsulation, information hiding, polymorphism and code sharing and their link with software reusability. ▸ Explain, using a concrete example, what polymorphism and dynamic binding is, and how it can lead to more maintainable code. ▸ Explain on a concrete example the concepts of method overriding, self and super calls. ▸ How can abstract classes and methods improve reusability? ▸ Explain, using a concrete example, how a multiple inheritance problem could be modelled in terms of single inheritance on classes and interfaces in Java.