History of Object Orientation

Download Report

Transcript History of Object Orientation

History of Object Orientation
What is Object-Orientation?
• Programming is one of the most complicated and difficult of
human activities.
• It helps a great deal if the program being developed is analogous
to a real world solution to the problem.
–
–
–
–
requirements are easier to understand,
more realism in the expectations of others,
debugging is eased by access to the real world solution
the system is less likely to be obsolete in the end.
• This informal approach—the design of the program reflects
objects and their behaviour in the real world—is called “objectoriented programming”
• First adopted by simulation programmers ca. 1960.
Strengths and Weaknesses of
Object-Orientation
• Strengths:
– the underlying objects are usually well-defined and
unchanging
– the structure of the solution is variable
• Weaknesses:
– It is often very hard to grasp the behaviour of the
system as a whole
– There is no ‘best’ object decomposition for a system of
any size.
• This approach is considered analogous to the way
humans think.
Start with Objects
• So we start with objects.
– Correspond to real things, having state and behaviour.
– Computation performed by objects communicating with each
other (“message passing”).
– Objects have memory (“state”), consisting of variables or
objects.
– Each object belongs to a class, which defines the behaviour
for objects in that class.
– Classes inherit behavior from other, more general classes,
forming a hierarchy.
• Alan Kay (1993) identified these characteristics as
fundamental to object-oriented programming.
Too Simple?
• Now this is clearly too simple.
• Consider a bat colony—the objects are bats, which communicate
and have memory.
• Much of their behaviour is general for bats, rather than specific
to an individual bat, but it is also clear that bats are individuals
and perform internal computation, so an object-oriented model of
a bat colony misses a lot of details.
• Also, bats change their behaviour (‘class’) with age.
• However, a model of the bat colony that fails to consider the bats
as individual behaving objects will be incomplete.
• An object-oriented model is useful
– A way to take individuals into consideration
A Definition
• Object-oriented design and programming is an
approach to defining a solution to a problem that
uses the system's natural structure as a system of
interacting objects to provide a programming
solution.
• Although it will still miss some of the constraints
that would apply to a real-world solution, it
provides an approach to design that promises to
reduce the space of alternative designs enough that
the programmer is no longer working with abstract
thought.
Ancestry of Object-Oriented
Programming
• The ancestry of object-oriented
programming can be found in imperative
and applicative languages. (Languages that
define processing instead of state and
relations.)
• The object-oriented paradigm emerged into
the general software community from the
simulation community in the early 1970s.
Simulation Objects
• Simulation programmers have always
viewed the world as objects and semantic
relationships, and this led to a natural
programming model consisting of objects
with
– Identity (object names or references)
– Behaviour (attributes or methods) and
– State (internal data).
Formalism and Simulation
• Theoretical workers have long been aware that
object-orientation is an inadequate model, because
– formal syntax cannot express semantics fully (Alan
Turing)
– the discrete representation of the world implicit in
programming means that formal syntax cannot express
causal entailment fully (Robert Rosen).
• BUT, it is an adequate approximation for our
purposes.
• Note: This means object-oriented programming
cannot be formalized completely.
ALGOL
• ALGOL 58 and 60 were early languages designed
to express the constructs of structured
programming in a fashion that could be reasoned
about effectively.
• Ancestors of many languages, including Pascal, C,
C++, C#, Java, Ada, and the simulation language,
Simula.
SIMULA
• SIMULA 1 and 67 were defined by Nygaard and Dahl as
object-oriented extensions of ALGOL.
• Given that object orientation did not exist at the time, it is
probably more accurate to describe it as a simulation
language based on ALGOL 60 that incorporated much of
what later would become known as object-orientation.
• In addition to the features most of us would recognize, it
incorporated something elegant called the ‘coroutine’.
– This is an instantiation of a subroutine with storage for input and
local data that could interact as an object with other coroutines.
– The corresponding concept in C++ and Java is the functor.
• An object that can be called as if it was a function.
SmallTalk
• SmallTalk (Goldberg and Robson, 1982) was a consistent
attempt to define computation as objects interfacing by
message passing.
• Everything, including primitive types, was an object, and
all function calls were implemented using messages.
• This included primitive arithmetic operations!
• Smalltalk is slow (at least ten times slower than C++) but
is easy to write in if you can understand the model of
computation.
Eiffel
• Eiffel was a language designed by Bertrand Meyer
(1988) to implement ‘design by contract’. (If
you're interested in exploring Eiffel, it is available
in the Metrowerks Codewarrior development
environment for the Macintosh.)
• Meyer’s work in this area was an attempt to
formalize object-oriented programming, and was
moderately successful.
• The principles of modularity (discussed later) are
from Meyer.
C++
• C++—Bjarne Stroustrup (Stroustrup,
various) designed C++ as ‘C with classes’ to
support his simulation work.
• This language has become remarkably
popular, and is one of the two major OO
languages (with Java) .
Java
• Java—A language deliberately designed for
object-oriented programming in embedded
environments.
• Popular for web and cross-platform independent
applications.
• Evolving towards C++.
C#
• C#—Microsoft lost a court case with SUN over its
specialization of Java for the ‘WINTEL’
environment. C# is Microsoft's attempt to take
over the niche occupied by Java. As part of this
strategy, Microsoft removed the Java Virtual
Machine from the Windows operating system,
which led to a further court case that they lost.
• Java 5 is quite similar to C#.
Ada
• Ada 95 (AARM, 1995) is the latest generation of Ada.
• Originally designed (on the basis of Pascal) to be a
high-reliability language for embedded systems, but
soon accumulated features to support almost any US
Department of Defense application.
• Not designed to be object-oriented, but during the
1980s-90s, support for object-oriented programming
was added to the wish-list.
• Named after Augusta Ada Byron, Lady Lovelace, a
daughter of Lord Byron and the first computer
programmer.
Conclusions
• Just like you can write FORTRAN in almost
any language, you can use objectorientation in almost any language, but…
• Some languages make it easier to be objectoriented.