SlideShare a Scribd company logo
1 of 70
Download to read offline
It Is Possible to Do
Object-Oriented
Programming in Java
Kevlin Henney
kevlin@curbralan.com
@KevlinHenney
The Java programming language
platform provides a portable,
interpreted, high-performance,
simple, object-oriented
programming language and
supporting run-time environment.
http://java.sun.com/docs/white/langenv/Intro.doc.html#318
OOP to me means only messaging,
local retention and protection
and hiding of state-process, and
extreme late-binding of all
things.
Alan Kay
OOP to me means only messaging,
local retention and protection
and hiding of state-process, and
extreme late-binding of all
things. It can be done in
Smalltalk and in LISP. There are
possibly other systems in which
this is possible, but I'm not
aware of them.
Alan Kay
Ignorance
Apathy
Selfishness
Encapsulation
Inheritance
Polymorphism
Encapsulation
Polymorphism
Inheritance
Encapsulation
Polymorphism
Inheritance
encapsulate enclose (something) in or as if in a capsule.
 express the essential feature of (someone or something)
succinctly.
 enclose (a message or signal) in a set of codes which
allow use by or transfer through different computer
systems or networks.
 provide an interface for (a piece of software or hardware)
to allow or simplify access for the user.
The New Oxford Dictionary of English
A distinction between inheritance and
subtyping is not often made: classes
are often equated directly with types.
From a behavioural point of view a
type defines characteristics and a
class defines an implementation of
these characteristics.
Kevlin Henney
Distributed Object-Oriented Computing:
The Development and Implementation of an Abstract Machine
In many object-oriented programming languages the concept of
inheritance is present, which provides a mechanism for sharing code
among several classes of objects. Many people even regard inheritance
as the hallmark of object-orientedness in programming languages. We
do not agree with this view, and argue that the essence of object-
oriented programming is the encapsulation of data and operations in
objects and the protection of individual objects against each other.
Pierre America
"A Behavioural Approach to Subtyping in Object-Oriented Programming Languages"
In many object-oriented programming languages the concept of
inheritance is present, which provides a mechanism for sharing code
among several classes of objects. Many people even regard inheritance
as the hallmark of object-orientedness in programming languages. We
do not agree with this view, and argue that the essence of object-
oriented programming is the encapsulation of data and operations in
objects and the protection of individual objects against each other.
The author considers this principle of protection of objects against each
other as the basic and essential characteristic of object-oriented
programming. It is a refinement of the technique of abstract data types,
because it does not only protect one type of objects against all other
types, but one object against all other ones. As a programmer we can
consider ourselves at any moment to be sitting in exactly one object and
looking at all the other objects from outside.
Pierre America
"A Behavioural Approach to Subtyping in Object-Oriented Programming Languages"
Object-oriented programming does not have
an exclusive claim to all these good properties.
Systems may be modeled by other paradigms.
Martín Abadi and Luca Cardelli
A Theory of Objects
Object-oriented programming does not have
an exclusive claim to all these good properties.
Systems may be modeled by other paradigms.
Resilience can be achieved just as well by
organizing programs around abstract data
types, independently of taxonomies; in fact,
data abstraction alone is sometimes taken as
the essence of object orientation.
Martín Abadi and Luca Cardelli
A Theory of Objects
abstraction, n. (Logic)
 the process of formulating a generalized concept of
a common property by disregarding the differences
between a number of particular instances. On such
an account, we acquired the concept of red by
recognizing it as common to, and so abstracting it
from the other properties of, those individual
objects we were originally taught to call red.
 an operator that forms a class name or predicate
from any given expression.
E J Borowski and J M Borwein
Dictionary of Mathematics
 T   RecentlyUsedList 
{
new : RecentlyUsedList[T],
isEmpty : RecentlyUsedList[T]  Boolean,
size : RecentlyUsedList[T]  Integer,
add : RecentlyUsedList[T]  Integer  RecentlyUsedList[T],
get : RecentlyUsedList[T]  Integer  T,
equals : RecentlyUsedList[T]  RecentlyUsedList[T]  Boolean
}
class RecentlyUsedList
{
private …
public boolean isEmpty() …
public int size() …
public void add(String toAdd) …
public String get(int index) …
public boolean equals(RecentlyUsedList other) …
}
class RecentlyUsedList
{
private …
public boolean isEmpty() …
public int size() …
public void add(String toAdd) …
public String get(int index) …
public boolean equals(RecentlyUsedList other) …
public boolean equals(Object other) …
}
class RecentlyUsedList
{
private List<String> items = new ArrayList<String>();
public boolean isEmpty()
{
return items.isEmpty();
}
public int size()
{
return items.size();
}
public void add(String toAdd)
{
items.remove(toAdd);
items.add(toAdd);
}
public String get(int index)
{
return items.get(size() – index – 1);
}
public boolean equals(RecentlyUsedList other)
{
return other != null && items.equals(other.items);
}
public boolean equals(Object other)
{
return
other instanceof RecentlyUsedList &&
equals((RecentlyUsedList) other);
}
}
typedef struct RecentlyUsedList RecentlyUsedList;
RecentlyUsedList * create();
void destroy(RecentlyUsedList *);
bool isEmpty(const RecentlyUsedList *);
int size(const RecentlyUsedList *);
void add(RecentlyUsedList *, int toAdd);
int get(const RecentlyUsedList *, int index);
bool equals(const RecentlyUsedList *, const RecentlyUsedList *);
struct RecentlyUsedList
{
int * items;
int length;
};
RecentlyUsedList * create()
{
RecentlyUsedList * result = (RecentlyUsedList *) malloc(sizeof(RecentlyUsedList));
result->items = 0;
result->length = 0;
return result;
}
void destroy(RecentlyUsedList * self)
{
free(self->items);
free(self);
}
bool isEmpty(const RecentlyUsedList * self)
{
return self->length == 0;
}
int size(const RecentlyUsedList * self)
{
return self->length;
}
static int indexOf(const RecentlyUsedList * self, int toFind)
{
int result = -1;
for(int index = 0; result == -1 && index != self->length; ++index)
if(self->items[index] == toFind)
result = index;
return result;
}
static void removeAt(RecentlyUsedList * self, int index)
{
memmove(&self->items[index], &self->items[index + 1], (self->length - index - 1) * sizeof(int));
--self->length;
}
void add(RecentlyUsedList * self, int toAdd)
{
int found = indexOf(self, toAdd);
if(found != -1)
removeAt(self, found);
self->items = (int *) realloc(self->items, (self->length + 1) * sizeof(int));
self->items[self->length] = toAdd;
++self->length;
}
int get(const RecentlyUsedList * self, int index)
{
return self->items[self->length - index - 1];
}
bool equals(const RecentlyUsedList * lhs, const RecentlyUsedList * rhs)
{
return lhs->length == rhs->length && memcmp(lhs->items, rhs->items, lhs->length * sizeof(int)) == 0;
}
struct RecentlyUsedList
{
std::vector<int> items;
};
extern "C"
{
RecentlyUsedList * create()
{
return new RecentlyUsedList;
}
void destroy(RecentlyUsedList * self)
{
delete self;
}
bool isEmpty(const RecentlyUsedList * self)
{
return self->items.empty();
}
int size(const RecentlyUsedList * self)
{
return self->items.size();
}
void add(RecentlyUsedList * self, int toAdd)
{
std::vector<int>::iterator found =
std::find(self->items.begin(), self->items.end(), toAdd);
if(found != self->items.end())
self->items.erase(found);
self->items.push_back(toAdd);
}
int get(const RecentlyUsedList * self, int index)
{
return self->items[self->items.size() - index - 1];
}
bool equals(const RecentlyUsedList * lhs, const RecentlyUsedList * rhs)
{
return lhs->items == rhs->items;
}
}
OO ≡ ADT?
OO ≡ ADT/
William Cook, "On Understanding Data Abstraction, Revisited"
class RecentlyUsedList
{
...
public boolean equals(RecentlyUsedList other)
{
return other != null && items.equals(other.items);
}
public boolean equals(Object other)
{
return
other instanceof RecentlyUsedList &&
equals((RecentlyUsedList) other);
}
}
bool equals(const RecentlyUsedList * lhs, const RecentlyUsedList * rhs)
{
return
lhs->length == rhs->length &&
memcmp(lhs->items, rhs->items, lhs->length * sizeof(int)) == 0;
}
extern "C"
{
...
bool equals(const RecentlyUsedList * lhs, const RecentlyUsedList * rhs)
{
return lhs->items == rhs->items;
}
}
Reflexivity: I am me. Symmetry: If you're the same
as me, I'm the same as you.
Transitivity: If I'm the same
as you, and you're the same
as them, then I'm the same
as them too.
Consistency: If there's no change,
everything's the same as it ever was.
Null inequality: I am not nothing.
Hash equality: If we're the same, we
both share the same magic numbers.
No throw: If you call,
I won't hang up.
Here are four common pitfalls that can cause
inconsistent behavior when overriding equals:
1. Defining equals with the wrong signature.
2. Changing equals without also changing hashCode.
3. Defining equals in terms of mutable fields.
4. Failing to define equals as an equivalence relation.
Martin Odersky, Lex Spoon and Bill Venners
"How to Write an Equality Method in Java"
http://www.artima.com/lejava/articles/equality.html
Here are four common pitfalls that can cause
inconsistent behavior when overriding equals:
1. Defining equals with the wrong signature.
2. Changing equals without also changing hashCode.
3. Relying on equals and hashCode to be invariant
when they depend on mutable fields.
4. Failing to define equals as an equivalence relation.
Here are four common pitfalls that can cause
inconsistent behavior when overriding equals:
1. Defining equals with the wrong signature.
2. Changing equals without also changing hashCode.
3. Failing to define equals as an equivalence relation.
4. Relying on equals and hashCode to be invariant
when they depend on mutable fields.
bool equals(
const RecentlyUsedList * lhs, const RecentlyUsedList * rhs)
{
bool result = size(lhs) == size(rhs);
for(int index = 0; result && index != size(lhs); ++index)
result = get(lhs, index) == get(rhs, index);
return result;
}
extern "C" bool equals(
const RecentlyUsedList * lhs, const RecentlyUsedList * rhs)
{
bool result = size(lhs) == size(rhs);
for(int index = 0; result && index != size(lhs); ++index)
result = get(lhs, index) == get(rhs, index);
return result;
}
class RecentlyUsedList
{
...
public boolean equals(RecentlyUsedList other)
{
boolean result = other != null && size() == other.size();
for(int index = 0; result && index != size(); ++index)
result = get(index).equals(other.get(index));
return result;
}
public boolean equals(Object other)
{
return
other instanceof RecentlyUsedList &&
equals((RecentlyUsedList) other);
}
}
One of the most pure object-oriented
programming models yet defined is the
Component Object Model (COM). It
enforces all of these principles rigorously.
Programming in COM is very flexible and
powerful as a result. There is no built-in notion
of equality. There is no way to determine if
an object is an instance of a given class.
William Cook
"On Understanding Data Abstraction, Revisited"
class RecentlyUsedList
{
...
public boolean equals(RecentlyUsedList other)
{
boolean result = other != null && size() == other.size();
for(int index = 0; result && index != size(); ++index)
result = get(index).equals(other.get(index));
return result;
}
public boolean equals(Object other)
{
return
other instanceof RecentlyUsedList &&
equals((RecentlyUsedList) other);
}
}
class RecentlyUsedList
{
...
public boolean equals(RecentlyUsedList other)
{
boolean result = other != null && size() == other.size();
for(int index = 0; result && index != size(); ++index)
result = get(index).equals(other.get(index));
return result;
}
}
In a purist view of object-oriented methodology,
dynamic dispatch is the only mechanism for
taking advantage of attributes that have been
forgotten by subsumption. This position is often
taken on abstraction grounds: no knowledge
should be obtainable about objects except by
invoking their methods. In the purist approach,
subsumption provides a simple and effective
mechanism for hiding private attributes.
Martín Abadi and Luca Cardelli, A Theory of Objects
A type hierarchy is composed of subtypes and
supertypes. The intuitive idea of a subtype is one
whose objects provide all the behavior of objects
of another type (the supertype) plus something
extra. What is wanted here is something like the
following substitution property: If for each
object o1 of type S there is an object o2 of type T
such that for all programs P defined in terms of T,
the behavior of P is unchanged when o1 is
substituted for o2, then S is a subtype of T.
Barbara Liskov
"Data Abstraction and Hierarchy"
A type hierarchy is composed of subtypes and
supertypes. The intuitive idea of a subtype is one
whose objects provide all the behavior of objects
of another type (the supertype) plus something
extra. What is wanted here is something like the
following substitution property: If for each
object o1 of type S there is an object o2 of type T
such that for all programs P defined in terms of T,
the behavior of P is unchanged when o1 is
substituted for o2, then S is a subtype of T.
Barbara Liskov
"Data Abstraction and Hierarchy"
A type hierarchy is composed of subtypes and
supertypes. The intuitive idea of a subtype is one
whose objects provide all the behavior of objects
of another type (the supertype) plus something
extra. What is wanted here is something like the
following substitution property: If for each
object o1 of type S there is an object o2 of type T
such that for all programs P defined in terms of T,
the behavior of P is unchanged when o1 is
substituted for o2, then S is a subtype of T.
Barbara Liskov
"Data Abstraction and Hierarchy"
A type hierarchy is composed of subtypes and
supertypes. The intuitive idea of a subtype is one
whose objects provide all the behavior of objects
of another type (the supertype) plus something
extra. What is wanted here is something like the
following substitution property: If for each
object o1 of type S there is an object o2 of type T
such that for all programs P defined in terms of T,
the behavior of P is unchanged when o1 is
substituted for o2, then S is a subtype of T.
Barbara Liskov
"Data Abstraction and Hierarchy"
William Cook, "On Understanding Data Abstraction, Revisited"
William Cook, "On Understanding Data Abstraction, Revisited"
interface RecentlyUsedList
{
boolean isEmpty();
int size();
void add(String toAdd);
String get(int index);
boolean equals(RecentlyUsedList other);
}
class RecentlyUsedListImpl
implements RecentlyUsedList
{
private List<String> items = …;
public boolean isEmpty() …
public int size() …
public void add(String toAdd) …
public String get(int index) …
public boolean equals(RecentlyUsedList other) …
public boolean equals(Object other) …
}
class ArrayListBasedRecentlyUsedList
implements RecentlyUsedList
{
private List<String> items = …;
public boolean isEmpty() …
public int size() …
public void add(String toAdd) …
public String get(int index) …
public boolean equals(RecentlyUsedList other) …
public boolean equals(Object other) …
}
class RandomAccessRecentlyUsedList
implements RecentlyUsedList
{
private List<String> items = …;
public boolean isEmpty() …
public int size() …
public void add(String toAdd) …
public String get(int index) …
public boolean equals(RecentlyUsedList other) …
public boolean equals(Object other) …
}
RecentlyUsedList list =
new RandomAccessRecentlyUsedList();
class RandomAccessRecentlyUsedList implements RecentlyUsedList
{
...
public boolean equals(RecentlyUsedList other)
{
boolean result = other != null && size() == other.size();
for(int index = 0; result && index != size(); ++index)
result = get(index).equals(other.get(index));
return result;
}
public boolean equals(Object other)
{
return
other instanceof RecentlyUsedList &&
equals((RecentlyUsedList) other);
}
}
Here are five common pitfalls that can cause
inconsistent behavior when overriding equals:
1. Defining equals with the wrong signature.
2. Changing equals without also changing hashCode.
3. Failing to define equals as an equivalence relation.
4. Defining equals in a class hierarchy where types
and classes are not properly distinguished.
5. Relying on equals and hashCode to be invariant
when they depend on mutable fields.
William Cook, "On Understanding Data Abstraction, Revisited"
newRecentlyUsedList =
  (let items = ref() 
{
isEmpty =   #items = 0,
size =   #items,
add =  x 
items := xˆitemsy  y  0...#items  itemsy  x,
get =  i  itemsi
})
var newRecentlyUsedList = function() {
var items = []
return {
isEmpty: function() {
return items.length === 0
},
size: function() {
return items.length
},
add: function(newItem) {
(items = items.filter(function(item) {
return item !== newItem
})).unshift(newItem)
},
get: function(index) {
return items[index]
}
}
}
var newRecentlyUsedList = function() {
var items = []
return {
...
supertypeOf: function(that) {
return that &&
that.isEmpty && that.size && that.add &&
that.get && that.supertypeOf && that.equals
},
equals: function(that) {
var result =
this.supertypeOf(that) &&
that.supertypeOf(this) &&
this.size() === that.size()
for(var i = 0; result && i !== this.size(); ++i)
result = this.get(i) === that.get(i)
return result
}
}
}
One of the most powerful mechanisms
for program structuring [...] is the block
and procedure concept. [...]
A procedure which is capable of giving
rise to block instances which survive its
call will be known as a class; and the
instances will be known as objects of
that class. [...]
A call of a class generates a new object
of that class.
Ole-Johan Dahl and C A R Hoare
"Hierarchical Program Structures"
Paradigms lost?
Or paradigms regained?
The venerable master Qc Na was walking with his student, Anton.
Hoping to prompt the master into a discussion, Anton said "Master, I
have heard that objects are a very good thing — is this true?" Qc Na
looked pityingly at his student and replied, "Foolish pupil — objects
are merely a poor man's closures."
Chastised, Anton took his leave from his master and returned to his
cell, intent on studying closures. He carefully read the entire "Lambda:
The Ultimate..." series of papers and its cousins, and implemented a
small Scheme interpreter with a closure-based object system. He
learned much, and looked forward to informing his master of his
progress.
On his next walk with Qc Na, Anton attempted to impress his master
by saying "Master, I have diligently studied the matter, and now
understand that objects are truly a poor man's closures." Qc Na
responded by hitting Anton with his stick, saying "When will you learn?
Closures are a poor man's object." At that moment, Anton became
enlightened.
http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html

More Related Content

What's hot

Farhaan Ahmed, BCA 2nd Year
Farhaan Ahmed, BCA 2nd YearFarhaan Ahmed, BCA 2nd Year
Farhaan Ahmed, BCA 2nd Yeardezyneecole
 
11 Using classes and objects
11 Using classes and objects11 Using classes and objects
11 Using classes and objectsmaznabili
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in PythonSujith Kumar
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object ReferencesTareq Hasan
 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)Ravi Kant Sahu
 
OOPS features using Objective C
OOPS features using Objective COOPS features using Objective C
OOPS features using Objective CTiyasi Acharya
 
SEMANTIC PARSING OF SIMPLE SENTENCES IN UNIFICATION-BASED VIETNAMESE GRAMMAR
SEMANTIC PARSING OF SIMPLE SENTENCES IN UNIFICATION-BASED VIETNAMESE GRAMMARSEMANTIC PARSING OF SIMPLE SENTENCES IN UNIFICATION-BASED VIETNAMESE GRAMMAR
SEMANTIC PARSING OF SIMPLE SENTENCES IN UNIFICATION-BASED VIETNAMESE GRAMMARijnlc
 
JavaScript OOPS Implimentation
JavaScript OOPS ImplimentationJavaScript OOPS Implimentation
JavaScript OOPS ImplimentationUsman Mehmood
 
Prototype Utility Methods(1)
Prototype Utility Methods(1)Prototype Utility Methods(1)
Prototype Utility Methods(1)mussawir20
 

What's hot (20)

JSpiders - Wrapper classes
JSpiders - Wrapper classesJSpiders - Wrapper classes
JSpiders - Wrapper classes
 
Java Wrapper Classes and I/O Mechanisms
Java Wrapper Classes and I/O MechanismsJava Wrapper Classes and I/O Mechanisms
Java Wrapper Classes and I/O Mechanisms
 
Basic concept of Object Oriented Programming
Basic concept of Object Oriented Programming Basic concept of Object Oriented Programming
Basic concept of Object Oriented Programming
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Farhaan Ahmed, BCA 2nd Year
Farhaan Ahmed, BCA 2nd YearFarhaan Ahmed, BCA 2nd Year
Farhaan Ahmed, BCA 2nd Year
 
11 Using classes and objects
11 Using classes and objects11 Using classes and objects
11 Using classes and objects
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in Python
 
JavsScript OOP
JavsScript OOPJavsScript OOP
JavsScript OOP
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)
 
OOPS features using Objective C
OOPS features using Objective COOPS features using Objective C
OOPS features using Objective C
 
Java
JavaJava
Java
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
SEMANTIC PARSING OF SIMPLE SENTENCES IN UNIFICATION-BASED VIETNAMESE GRAMMAR
SEMANTIC PARSING OF SIMPLE SENTENCES IN UNIFICATION-BASED VIETNAMESE GRAMMARSEMANTIC PARSING OF SIMPLE SENTENCES IN UNIFICATION-BASED VIETNAMESE GRAMMAR
SEMANTIC PARSING OF SIMPLE SENTENCES IN UNIFICATION-BASED VIETNAMESE GRAMMAR
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
Ruby object model
Ruby object modelRuby object model
Ruby object model
 
JavaScript OOPS Implimentation
JavaScript OOPS ImplimentationJavaScript OOPS Implimentation
JavaScript OOPS Implimentation
 
Ajaxworld
AjaxworldAjaxworld
Ajaxworld
 
Prototype Utility Methods(1)
Prototype Utility Methods(1)Prototype Utility Methods(1)
Prototype Utility Methods(1)
 

Viewers also liked

oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with JavaJussi Pohjolainen
 
Power Point Presentation on Accounting Concepts and Principles
Power Point Presentation on Accounting Concepts and PrinciplesPower Point Presentation on Accounting Concepts and Principles
Power Point Presentation on Accounting Concepts and Principlesjinulazer
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 
Chapter 1: Fundamentals of Accounting
Chapter 1: Fundamentals of AccountingChapter 1: Fundamentals of Accounting
Chapter 1: Fundamentals of AccountingAfzalur Rahman
 
Basics of accounting
Basics of accountingBasics of accounting
Basics of accountingajithjoanes
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedSlideShare
 
From Selling 2 Books a Day, To 200 - How I Did It? - J. Thorn
From Selling 2 Books a Day, To 200 - How I Did It? - J. ThornFrom Selling 2 Books a Day, To 200 - How I Did It? - J. Thorn
From Selling 2 Books a Day, To 200 - How I Did It? - J. ThornJim Kukral
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in javaagorolabs
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Michelle Anne Meralpis
 
1. principles of accounting
1. principles of accounting1. principles of accounting
1. principles of accountingAmaan Hussain
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
Introduction to Basic Accounting Concept
Introduction to Basic Accounting ConceptIntroduction to Basic Accounting Concept
Introduction to Basic Accounting ConceptKamrul Hasan
 
Presentation on Accounting Principles
Presentation on Accounting Principles  Presentation on Accounting Principles
Presentation on Accounting Principles Zakir Khan
 

Viewers also liked (20)

oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Power Point Presentation on Accounting Concepts and Principles
Power Point Presentation on Accounting Concepts and PrinciplesPower Point Presentation on Accounting Concepts and Principles
Power Point Presentation on Accounting Concepts and Principles
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Chapter 1: Fundamentals of Accounting
Chapter 1: Fundamentals of AccountingChapter 1: Fundamentals of Accounting
Chapter 1: Fundamentals of Accounting
 
Basics of accounting
Basics of accountingBasics of accounting
Basics of accounting
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-Presented
 
From Selling 2 Books a Day, To 200 - How I Did It? - J. Thorn
From Selling 2 Books a Day, To 200 - How I Did It? - J. ThornFrom Selling 2 Books a Day, To 200 - How I Did It? - J. Thorn
From Selling 2 Books a Day, To 200 - How I Did It? - J. Thorn
 
Java basic
Java basicJava basic
Java basic
 
Java for C++ programers
Java for C++ programersJava for C++ programers
Java for C++ programers
 
Java Object Oriented Programming
Java Object Oriented Programming Java Object Oriented Programming
Java Object Oriented Programming
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
 
Oop java
Oop javaOop java
Oop java
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
1. principles of accounting
1. principles of accounting1. principles of accounting
1. principles of accounting
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Introduction to Basic Accounting Concept
Introduction to Basic Accounting ConceptIntroduction to Basic Accounting Concept
Introduction to Basic Accounting Concept
 
Presentation on Accounting Principles
Presentation on Accounting Principles  Presentation on Accounting Principles
Presentation on Accounting Principles
 

Similar to It Is Possible to Do Object-Oriented Programming in Java

SOLID Deconstruction
SOLID DeconstructionSOLID Deconstruction
SOLID DeconstructionKevlin Henney
 
Solid Deconstruction
Solid DeconstructionSolid Deconstruction
Solid DeconstructionKevlin Henney
 
PRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxPRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxabhishek364864
 
Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insAndrew Dupont
 
Introduction to javascript and yoolkui
Introduction to javascript and yoolkuiIntroduction to javascript and yoolkui
Introduction to javascript and yoolkuiKhou Suylong
 
Object? You Keep Using that Word
Object? You Keep Using that WordObject? You Keep Using that Word
Object? You Keep Using that WordKevlin Henney
 
FP vs OOP : Design Methodology by Harshad Nawathe
FP vs OOP : Design Methodology by Harshad NawatheFP vs OOP : Design Methodology by Harshad Nawathe
FP vs OOP : Design Methodology by Harshad NawatheChandulal Kavar
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshowilias ahmed
 
SOLID Deconstruction
SOLID DeconstructionSOLID Deconstruction
SOLID DeconstructionKevlin Henney
 
Introduction to object oriented programming
Introduction to object oriented programmingIntroduction to object oriented programming
Introduction to object oriented programmingAbzetdin Adamov
 
Lecture20 vector
Lecture20 vectorLecture20 vector
Lecture20 vectornurkhaledah
 
From Java to Python: beating the Stockholm syndrome
From Java to Python: beating the Stockholm syndromeFrom Java to Python: beating the Stockholm syndrome
From Java to Python: beating the Stockholm syndromeJavier Arias Losada
 
Cordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptCordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptBinu Paul
 

Similar to It Is Possible to Do Object-Oriented Programming in Java (20)

SOLID Deconstruction
SOLID DeconstructionSOLID Deconstruction
SOLID Deconstruction
 
Solid Deconstruction
Solid DeconstructionSolid Deconstruction
Solid Deconstruction
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
OOP Principles
OOP PrinciplesOOP Principles
OOP Principles
 
PRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxPRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptx
 
Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-ins
 
Introduction to javascript and yoolkui
Introduction to javascript and yoolkuiIntroduction to javascript and yoolkui
Introduction to javascript and yoolkui
 
Object? You Keep Using that Word
Object? You Keep Using that WordObject? You Keep Using that Word
Object? You Keep Using that Word
 
FP vs OOP : Design Methodology by Harshad Nawathe
FP vs OOP : Design Methodology by Harshad NawatheFP vs OOP : Design Methodology by Harshad Nawathe
FP vs OOP : Design Methodology by Harshad Nawathe
 
Lecture 5.pptx
Lecture 5.pptxLecture 5.pptx
Lecture 5.pptx
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
 
OOP by hrishikesh dhola
OOP by hrishikesh dholaOOP by hrishikesh dhola
OOP by hrishikesh dhola
 
SOLID Deconstruction
SOLID DeconstructionSOLID Deconstruction
SOLID Deconstruction
 
Introduction to object oriented programming
Introduction to object oriented programmingIntroduction to object oriented programming
Introduction to object oriented programming
 
Python for Dummies
Python for DummiesPython for Dummies
Python for Dummies
 
Lecture20 vector
Lecture20 vectorLecture20 vector
Lecture20 vector
 
From Java to Python: beating the Stockholm syndrome
From Java to Python: beating the Stockholm syndromeFrom Java to Python: beating the Stockholm syndrome
From Java to Python: beating the Stockholm syndrome
 
Cordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptCordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced Javascript
 
SEMINAR
SEMINARSEMINAR
SEMINAR
 

More from Kevlin Henney

The Case for Technical Excellence
The Case for Technical ExcellenceThe Case for Technical Excellence
The Case for Technical ExcellenceKevlin Henney
 
Empirical Development
Empirical DevelopmentEmpirical Development
Empirical DevelopmentKevlin Henney
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that LetterKevlin Henney
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that LetterKevlin Henney
 
Procedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went AwayProcedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went AwayKevlin Henney
 
Structure and Interpretation of Test Cases
Structure and Interpretation of Test CasesStructure and Interpretation of Test Cases
Structure and Interpretation of Test CasesKevlin Henney
 
Refactoring to Immutability
Refactoring to ImmutabilityRefactoring to Immutability
Refactoring to ImmutabilityKevlin Henney
 
Turning Development Outside-In
Turning Development Outside-InTurning Development Outside-In
Turning Development Outside-InKevlin Henney
 
Giving Code a Good Name
Giving Code a Good NameGiving Code a Good Name
Giving Code a Good NameKevlin Henney
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Kevlin Henney
 
Thinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation QuadrantThinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation QuadrantKevlin Henney
 
The Error of Our Ways
The Error of Our WaysThe Error of Our Ways
The Error of Our WaysKevlin Henney
 

More from Kevlin Henney (20)

Program with GUTs
Program with GUTsProgram with GUTs
Program with GUTs
 
The Case for Technical Excellence
The Case for Technical ExcellenceThe Case for Technical Excellence
The Case for Technical Excellence
 
Empirical Development
Empirical DevelopmentEmpirical Development
Empirical Development
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that Letter
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that Letter
 
Get Kata
Get KataGet Kata
Get Kata
 
Procedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went AwayProcedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went Away
 
Structure and Interpretation of Test Cases
Structure and Interpretation of Test CasesStructure and Interpretation of Test Cases
Structure and Interpretation of Test Cases
 
Agility ≠ Speed
Agility ≠ SpeedAgility ≠ Speed
Agility ≠ Speed
 
Refactoring to Immutability
Refactoring to ImmutabilityRefactoring to Immutability
Refactoring to Immutability
 
Old Is the New New
Old Is the New NewOld Is the New New
Old Is the New New
 
Turning Development Outside-In
Turning Development Outside-InTurning Development Outside-In
Turning Development Outside-In
 
Giving Code a Good Name
Giving Code a Good NameGiving Code a Good Name
Giving Code a Good Name
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
 
Thinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation QuadrantThinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation Quadrant
 
Code as Risk
Code as RiskCode as Risk
Code as Risk
 
Software Is Details
Software Is DetailsSoftware Is Details
Software Is Details
 
Game of Sprints
Game of SprintsGame of Sprints
Game of Sprints
 
Good Code
Good CodeGood Code
Good Code
 
The Error of Our Ways
The Error of Our WaysThe Error of Our Ways
The Error of Our Ways
 

Recently uploaded

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 

Recently uploaded (20)

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 

It Is Possible to Do Object-Oriented Programming in Java

  • 1. It Is Possible to Do Object-Oriented Programming in Java Kevlin Henney kevlin@curbralan.com @KevlinHenney
  • 2.
  • 3.
  • 4. The Java programming language platform provides a portable, interpreted, high-performance, simple, object-oriented programming language and supporting run-time environment. http://java.sun.com/docs/white/langenv/Intro.doc.html#318
  • 5. OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. Alan Kay
  • 6. OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them. Alan Kay
  • 11. encapsulate enclose (something) in or as if in a capsule.  express the essential feature of (someone or something) succinctly.  enclose (a message or signal) in a set of codes which allow use by or transfer through different computer systems or networks.  provide an interface for (a piece of software or hardware) to allow or simplify access for the user. The New Oxford Dictionary of English
  • 12.
  • 13. A distinction between inheritance and subtyping is not often made: classes are often equated directly with types. From a behavioural point of view a type defines characteristics and a class defines an implementation of these characteristics. Kevlin Henney Distributed Object-Oriented Computing: The Development and Implementation of an Abstract Machine
  • 14.
  • 15. In many object-oriented programming languages the concept of inheritance is present, which provides a mechanism for sharing code among several classes of objects. Many people even regard inheritance as the hallmark of object-orientedness in programming languages. We do not agree with this view, and argue that the essence of object- oriented programming is the encapsulation of data and operations in objects and the protection of individual objects against each other. Pierre America "A Behavioural Approach to Subtyping in Object-Oriented Programming Languages"
  • 16. In many object-oriented programming languages the concept of inheritance is present, which provides a mechanism for sharing code among several classes of objects. Many people even regard inheritance as the hallmark of object-orientedness in programming languages. We do not agree with this view, and argue that the essence of object- oriented programming is the encapsulation of data and operations in objects and the protection of individual objects against each other. The author considers this principle of protection of objects against each other as the basic and essential characteristic of object-oriented programming. It is a refinement of the technique of abstract data types, because it does not only protect one type of objects against all other types, but one object against all other ones. As a programmer we can consider ourselves at any moment to be sitting in exactly one object and looking at all the other objects from outside. Pierre America "A Behavioural Approach to Subtyping in Object-Oriented Programming Languages"
  • 17. Object-oriented programming does not have an exclusive claim to all these good properties. Systems may be modeled by other paradigms. Martín Abadi and Luca Cardelli A Theory of Objects
  • 18. Object-oriented programming does not have an exclusive claim to all these good properties. Systems may be modeled by other paradigms. Resilience can be achieved just as well by organizing programs around abstract data types, independently of taxonomies; in fact, data abstraction alone is sometimes taken as the essence of object orientation. Martín Abadi and Luca Cardelli A Theory of Objects
  • 19. abstraction, n. (Logic)  the process of formulating a generalized concept of a common property by disregarding the differences between a number of particular instances. On such an account, we acquired the concept of red by recognizing it as common to, and so abstracting it from the other properties of, those individual objects we were originally taught to call red.  an operator that forms a class name or predicate from any given expression. E J Borowski and J M Borwein Dictionary of Mathematics
  • 20.  T   RecentlyUsedList  { new : RecentlyUsedList[T], isEmpty : RecentlyUsedList[T]  Boolean, size : RecentlyUsedList[T]  Integer, add : RecentlyUsedList[T]  Integer  RecentlyUsedList[T], get : RecentlyUsedList[T]  Integer  T, equals : RecentlyUsedList[T]  RecentlyUsedList[T]  Boolean }
  • 21. class RecentlyUsedList { private … public boolean isEmpty() … public int size() … public void add(String toAdd) … public String get(int index) … public boolean equals(RecentlyUsedList other) … }
  • 22. class RecentlyUsedList { private … public boolean isEmpty() … public int size() … public void add(String toAdd) … public String get(int index) … public boolean equals(RecentlyUsedList other) … public boolean equals(Object other) … }
  • 23. class RecentlyUsedList { private List<String> items = new ArrayList<String>(); public boolean isEmpty() { return items.isEmpty(); } public int size() { return items.size(); } public void add(String toAdd) { items.remove(toAdd); items.add(toAdd); } public String get(int index) { return items.get(size() – index – 1); } public boolean equals(RecentlyUsedList other) { return other != null && items.equals(other.items); } public boolean equals(Object other) { return other instanceof RecentlyUsedList && equals((RecentlyUsedList) other); } }
  • 24. typedef struct RecentlyUsedList RecentlyUsedList; RecentlyUsedList * create(); void destroy(RecentlyUsedList *); bool isEmpty(const RecentlyUsedList *); int size(const RecentlyUsedList *); void add(RecentlyUsedList *, int toAdd); int get(const RecentlyUsedList *, int index); bool equals(const RecentlyUsedList *, const RecentlyUsedList *);
  • 25. struct RecentlyUsedList { int * items; int length; };
  • 26. RecentlyUsedList * create() { RecentlyUsedList * result = (RecentlyUsedList *) malloc(sizeof(RecentlyUsedList)); result->items = 0; result->length = 0; return result; } void destroy(RecentlyUsedList * self) { free(self->items); free(self); } bool isEmpty(const RecentlyUsedList * self) { return self->length == 0; } int size(const RecentlyUsedList * self) { return self->length; } static int indexOf(const RecentlyUsedList * self, int toFind) { int result = -1; for(int index = 0; result == -1 && index != self->length; ++index) if(self->items[index] == toFind) result = index; return result; } static void removeAt(RecentlyUsedList * self, int index) { memmove(&self->items[index], &self->items[index + 1], (self->length - index - 1) * sizeof(int)); --self->length; } void add(RecentlyUsedList * self, int toAdd) { int found = indexOf(self, toAdd); if(found != -1) removeAt(self, found); self->items = (int *) realloc(self->items, (self->length + 1) * sizeof(int)); self->items[self->length] = toAdd; ++self->length; } int get(const RecentlyUsedList * self, int index) { return self->items[self->length - index - 1]; } bool equals(const RecentlyUsedList * lhs, const RecentlyUsedList * rhs) { return lhs->length == rhs->length && memcmp(lhs->items, rhs->items, lhs->length * sizeof(int)) == 0; }
  • 28. extern "C" { RecentlyUsedList * create() { return new RecentlyUsedList; } void destroy(RecentlyUsedList * self) { delete self; } bool isEmpty(const RecentlyUsedList * self) { return self->items.empty(); } int size(const RecentlyUsedList * self) { return self->items.size(); } void add(RecentlyUsedList * self, int toAdd) { std::vector<int>::iterator found = std::find(self->items.begin(), self->items.end(), toAdd); if(found != self->items.end()) self->items.erase(found); self->items.push_back(toAdd); } int get(const RecentlyUsedList * self, int index) { return self->items[self->items.size() - index - 1]; } bool equals(const RecentlyUsedList * lhs, const RecentlyUsedList * rhs) { return lhs->items == rhs->items; } }
  • 31. William Cook, "On Understanding Data Abstraction, Revisited"
  • 32. class RecentlyUsedList { ... public boolean equals(RecentlyUsedList other) { return other != null && items.equals(other.items); } public boolean equals(Object other) { return other instanceof RecentlyUsedList && equals((RecentlyUsedList) other); } }
  • 33. bool equals(const RecentlyUsedList * lhs, const RecentlyUsedList * rhs) { return lhs->length == rhs->length && memcmp(lhs->items, rhs->items, lhs->length * sizeof(int)) == 0; }
  • 34. extern "C" { ... bool equals(const RecentlyUsedList * lhs, const RecentlyUsedList * rhs) { return lhs->items == rhs->items; } }
  • 35. Reflexivity: I am me. Symmetry: If you're the same as me, I'm the same as you. Transitivity: If I'm the same as you, and you're the same as them, then I'm the same as them too. Consistency: If there's no change, everything's the same as it ever was. Null inequality: I am not nothing. Hash equality: If we're the same, we both share the same magic numbers. No throw: If you call, I won't hang up.
  • 36. Here are four common pitfalls that can cause inconsistent behavior when overriding equals: 1. Defining equals with the wrong signature. 2. Changing equals without also changing hashCode. 3. Defining equals in terms of mutable fields. 4. Failing to define equals as an equivalence relation. Martin Odersky, Lex Spoon and Bill Venners "How to Write an Equality Method in Java" http://www.artima.com/lejava/articles/equality.html
  • 37. Here are four common pitfalls that can cause inconsistent behavior when overriding equals: 1. Defining equals with the wrong signature. 2. Changing equals without also changing hashCode. 3. Relying on equals and hashCode to be invariant when they depend on mutable fields. 4. Failing to define equals as an equivalence relation.
  • 38. Here are four common pitfalls that can cause inconsistent behavior when overriding equals: 1. Defining equals with the wrong signature. 2. Changing equals without also changing hashCode. 3. Failing to define equals as an equivalence relation. 4. Relying on equals and hashCode to be invariant when they depend on mutable fields.
  • 39. bool equals( const RecentlyUsedList * lhs, const RecentlyUsedList * rhs) { bool result = size(lhs) == size(rhs); for(int index = 0; result && index != size(lhs); ++index) result = get(lhs, index) == get(rhs, index); return result; }
  • 40. extern "C" bool equals( const RecentlyUsedList * lhs, const RecentlyUsedList * rhs) { bool result = size(lhs) == size(rhs); for(int index = 0; result && index != size(lhs); ++index) result = get(lhs, index) == get(rhs, index); return result; }
  • 41. class RecentlyUsedList { ... public boolean equals(RecentlyUsedList other) { boolean result = other != null && size() == other.size(); for(int index = 0; result && index != size(); ++index) result = get(index).equals(other.get(index)); return result; } public boolean equals(Object other) { return other instanceof RecentlyUsedList && equals((RecentlyUsedList) other); } }
  • 42. One of the most pure object-oriented programming models yet defined is the Component Object Model (COM). It enforces all of these principles rigorously. Programming in COM is very flexible and powerful as a result. There is no built-in notion of equality. There is no way to determine if an object is an instance of a given class. William Cook "On Understanding Data Abstraction, Revisited"
  • 43. class RecentlyUsedList { ... public boolean equals(RecentlyUsedList other) { boolean result = other != null && size() == other.size(); for(int index = 0; result && index != size(); ++index) result = get(index).equals(other.get(index)); return result; } public boolean equals(Object other) { return other instanceof RecentlyUsedList && equals((RecentlyUsedList) other); } }
  • 44. class RecentlyUsedList { ... public boolean equals(RecentlyUsedList other) { boolean result = other != null && size() == other.size(); for(int index = 0; result && index != size(); ++index) result = get(index).equals(other.get(index)); return result; } }
  • 45. In a purist view of object-oriented methodology, dynamic dispatch is the only mechanism for taking advantage of attributes that have been forgotten by subsumption. This position is often taken on abstraction grounds: no knowledge should be obtainable about objects except by invoking their methods. In the purist approach, subsumption provides a simple and effective mechanism for hiding private attributes. Martín Abadi and Luca Cardelli, A Theory of Objects
  • 46. A type hierarchy is composed of subtypes and supertypes. The intuitive idea of a subtype is one whose objects provide all the behavior of objects of another type (the supertype) plus something extra. What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2, then S is a subtype of T. Barbara Liskov "Data Abstraction and Hierarchy"
  • 47. A type hierarchy is composed of subtypes and supertypes. The intuitive idea of a subtype is one whose objects provide all the behavior of objects of another type (the supertype) plus something extra. What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2, then S is a subtype of T. Barbara Liskov "Data Abstraction and Hierarchy"
  • 48. A type hierarchy is composed of subtypes and supertypes. The intuitive idea of a subtype is one whose objects provide all the behavior of objects of another type (the supertype) plus something extra. What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2, then S is a subtype of T. Barbara Liskov "Data Abstraction and Hierarchy"
  • 49. A type hierarchy is composed of subtypes and supertypes. The intuitive idea of a subtype is one whose objects provide all the behavior of objects of another type (the supertype) plus something extra. What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2, then S is a subtype of T. Barbara Liskov "Data Abstraction and Hierarchy"
  • 50. William Cook, "On Understanding Data Abstraction, Revisited"
  • 51. William Cook, "On Understanding Data Abstraction, Revisited"
  • 52. interface RecentlyUsedList { boolean isEmpty(); int size(); void add(String toAdd); String get(int index); boolean equals(RecentlyUsedList other); }
  • 53. class RecentlyUsedListImpl implements RecentlyUsedList { private List<String> items = …; public boolean isEmpty() … public int size() … public void add(String toAdd) … public String get(int index) … public boolean equals(RecentlyUsedList other) … public boolean equals(Object other) … }
  • 54. class ArrayListBasedRecentlyUsedList implements RecentlyUsedList { private List<String> items = …; public boolean isEmpty() … public int size() … public void add(String toAdd) … public String get(int index) … public boolean equals(RecentlyUsedList other) … public boolean equals(Object other) … }
  • 55. class RandomAccessRecentlyUsedList implements RecentlyUsedList { private List<String> items = …; public boolean isEmpty() … public int size() … public void add(String toAdd) … public String get(int index) … public boolean equals(RecentlyUsedList other) … public boolean equals(Object other) … }
  • 56. RecentlyUsedList list = new RandomAccessRecentlyUsedList();
  • 57. class RandomAccessRecentlyUsedList implements RecentlyUsedList { ... public boolean equals(RecentlyUsedList other) { boolean result = other != null && size() == other.size(); for(int index = 0; result && index != size(); ++index) result = get(index).equals(other.get(index)); return result; } public boolean equals(Object other) { return other instanceof RecentlyUsedList && equals((RecentlyUsedList) other); } }
  • 58. Here are five common pitfalls that can cause inconsistent behavior when overriding equals: 1. Defining equals with the wrong signature. 2. Changing equals without also changing hashCode. 3. Failing to define equals as an equivalence relation. 4. Defining equals in a class hierarchy where types and classes are not properly distinguished. 5. Relying on equals and hashCode to be invariant when they depend on mutable fields.
  • 59.
  • 60. William Cook, "On Understanding Data Abstraction, Revisited"
  • 61. newRecentlyUsedList =   (let items = ref()  { isEmpty =   #items = 0, size =   #items, add =  x  items := xˆitemsy  y  0...#items  itemsy  x, get =  i  itemsi })
  • 62. var newRecentlyUsedList = function() { var items = [] return { isEmpty: function() { return items.length === 0 }, size: function() { return items.length }, add: function(newItem) { (items = items.filter(function(item) { return item !== newItem })).unshift(newItem) }, get: function(index) { return items[index] } } }
  • 63. var newRecentlyUsedList = function() { var items = [] return { ... supertypeOf: function(that) { return that && that.isEmpty && that.size && that.add && that.get && that.supertypeOf && that.equals }, equals: function(that) { var result = this.supertypeOf(that) && that.supertypeOf(this) && this.size() === that.size() for(var i = 0; result && i !== this.size(); ++i) result = this.get(i) === that.get(i) return result } } }
  • 64.
  • 65. One of the most powerful mechanisms for program structuring [...] is the block and procedure concept. [...] A procedure which is capable of giving rise to block instances which survive its call will be known as a class; and the instances will be known as objects of that class. [...] A call of a class generates a new object of that class. Ole-Johan Dahl and C A R Hoare "Hierarchical Program Structures"
  • 68.
  • 69.
  • 70. The venerable master Qc Na was walking with his student, Anton. Hoping to prompt the master into a discussion, Anton said "Master, I have heard that objects are a very good thing — is this true?" Qc Na looked pityingly at his student and replied, "Foolish pupil — objects are merely a poor man's closures." Chastised, Anton took his leave from his master and returned to his cell, intent on studying closures. He carefully read the entire "Lambda: The Ultimate..." series of papers and its cousins, and implemented a small Scheme interpreter with a closure-based object system. He learned much, and looked forward to informing his master of his progress. On his next walk with Qc Na, Anton attempted to impress his master by saying "Master, I have diligently studied the matter, and now understand that objects are truly a poor man's closures." Qc Na responded by hitting Anton with his stick, saying "When will you learn? Closures are a poor man's object." At that moment, Anton became enlightened. http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html