The document discusses object-oriented programming and data abstraction. It argues that encapsulation of data and operations within objects is the essence of OOP, rather than inheritance. Data abstraction alone, through defining abstract data types, can achieve many of the benefits of OOP such as resilience. OOP can be viewed as an evolution of the technique of abstract data types, with the added characteristic of protection of individual objects from one another.
5. Agglutination is a process in linguistic morphology
derivation in which complex words are formed by
stringing together morphemes, each with a single
grammatical or semantic meaning. Languages that
use agglutination widely are called agglutinative
languages.
http://en.wikipedia.org/wiki/Agglutination
10. People will be using the
words you choose in their
conversation for the next 20
years. You want to be sure
you do it right.
Unfortunately, many people
get all formal [...]. Just calling
it what it is isn't enough.
11. They have to tack on a
flowery, computer science-y,
impressive sounding, but
ultimately meaningless word,
like Object, Thing,
Component, Part, Manager,
Entity, or Item.
14. public interface BookEntity ...
public interface BookEntityFactory ...
public interface ISBNValidator ...
public interface CatalogueRepository ...
public interface CatalogueRepositoryProvider ...
public abstract class AbstractBookEntity
implements BookEntity
public class BookEntityImpl
extends AbstractBookEntity ...
public class BookEntityFactoryImpl
implements BookEntityFactory ...
public class ISBNValidatorImpl
implements ISBNValidator ...
public class CatalogueRepositoryImpl
implements CatalogueRepository ...
public class CatalogueRepositoryProviderImpl
implements CatalogueRepositoryProvider ...
15. public interface Book ...
public final class ISBN ...
public interface Catalogue ...
public class DescriptionOfCatalogueImplementation
implements Catalogue ...
16. managerialism, noun
belief in or reliance on the use of professional
managers in administering or planning an activity
application of managerial techniques of businesses
to the running of other organisations, such as the
civil service or local authorities
belief in the importance of tightly managed
organisations, as opposed to individuals, or
groups that do not resemble an organisation
Concise Oxford English Dictionary ∙ Dictionary.com ∙ Wikipedia
17. One way to name classes is to
give each a unique name,
indicative of its purpose. Unique
names give you the opportunity
to convey a lot of information
without creating names that are
long and unwieldy.
This is exactly the right thing to do
if the names are in common use.
21. role, noun
an actor's part in a play, film, etc.
a person or thing's function in a particular
situation
a function, part or expected behaviour
performed in a particular operation or process
Concise Oxford English Dictionary ∙ Merriam-Webster's Collegiate Dictionary
28. You can communicate how the new
class is the same by naming some
superclass. It need not be the
immediate superclass, if some distant
ancestor communicates more
clearly.
You can communicate how the new
class is different by finding a word
that accurately highlights the reason
the new class isn't just the superclass.
33. 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
41. An interface is a contract to deliver
a certain amount of service.
Clients of the interface depend on
the contract, which is usually
documented in the interface
specification.
Butler W Lampson
"Hints for Computer System Design"
42.
43. Stack[T]
{
push(T item),
pop(),
depth() : Integer,
top() : T
}
given:
before = depth()
postcondition:
depth() = before + 1 ∧ top() = item
precondition:
depth() > 0
given:
before = depth()
precondition:
before > 0
postcondition:
depth() = before – 1
given:
result = depth()
postcondition:
result ≥ 0
48. public class Stack_spec
{
public static class A_new_stack
{
@Test
public void has_no_depth()
@Test()
public void has_no_top()
}
public static class An_empty_stack
{
@Test()
public void throws_when_popped()
@Test
public void acquires_depth_by_retaining_a_pushed_item_as_its_top()
}
public static class A_non_empty_stack
{
@Test
public void becomes_deeper_by_retaining_a_pushed_item_as_its_top()
@Test
public void on_popping_reveals_tops_in_reverse_order_of_pushing()
}
}
49. public class
Stack_spec
{
public static class
A_new_stack
{
@Test
public void has_no_depth()
@Test()
public void has_no_top()
}
public static class
An_empty_stack
{
@Test()
public void throws_when_popped()
@Test
public void acquires_depth_by_retaining_a_pushed_item_as_its_top()
}
public static class
A_non_empty_stack
{
@Test
public void becomes_deeper_by_retaining_a_pushed_item_as_its_top()
@Test
public void on_popping_reveals_tops_in_reverse_order_of_pushing()
}
}
50. public class
Stack_spec
{
public static class
A_new_stack
{
@Test
public void has_no_depth()
@Test()
public void has_no_top()
}
public static class
An_empty_stack
{
@Test()
public void throws_when_popped()
@Test
public void acquires_depth_by_retaining_a_pushed_item_as_its_top()
}
public static class
A_non_empty_stack
{
@Test
public void becomes_deeper_by_retaining_a_pushed_item_as_its_top()
@Test
public void on_popping_reveals_tops_in_reverse_order_of_pushing()
}
}
51.
52. Many objects have no conceptual
identity. These objects describe
some characteristic of a thing.
53. When you care only about the
attributes of an element of the
model, classify it as a value
object. Make it express the
meaning of the attributes it
conveys and give it related
functionality. Treat the value
object as immutable. Don't give it
any identity and avoid the design
complexities necessary to
maintain entities.
59. encapsulate, verb
enclose (something) in or as if in a capsule.
express the essential feature of (someone or
something) succinctly.
provide an interface for (a piece of software or
hardware) to allow or simplify access for the user.
The New Oxford Dictionary of English
60. 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"
61. 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"
62.
63. 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.
64. 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
66. public class RecentlyUsedList
{
private …
public boolean isEmpty() …
public int size() …
public void add(String toAdd) …
public String get(int index) …
public boolean equals(RecentlyUsedList other) …
}
67. public 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) …
}
68. public 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);
}
}
69. 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 *);
80. 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;
}
81. 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;
}
82. public 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);
}
}
83. 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"
84. public 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);
}
}
85. public 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;
}
}
86. 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.
89. public 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) …
}
90. public 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) …
}
91. public 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) …
}