The Symbian OS (779886), страница 24
Текст из файла (страница 24)
At root, it is away of thinking, a programming style, a particular approach to modeling6It is ten years since Richard Gabriel’s book was published and he was using the pasttense even then.7The annual CHAOS report from the Standish Group includes IT project resolutionstatistics. The 1994 report claimed that 31% of software projects are cancelled, with afurther 16% either over budget, late or reduced in the scope of their features or functionscompared to the initial specification.
In 2004, the numbers were respectively 29% and 18%(see www.standishgroup.com).8These were the radical slogans which accompanied the announcement of the ‘softwarecrisis’ and which were aimed at overturning the crisis, see [Assmann 2003, p. 6].9This phrase is attributed to Netscape’s Jim Clark, see [Lewis 1999].10For a discussion of terminology and many interesting insights into object orientation,including the object-oriented conceptual framework, see [Madsen et al. 1993, p. 9].
Ingeneral, I try to follow the BETA language terminology: ‘object orientation’ is an outlook orperspective; ‘object-oriented’ is an attribute of specific tools or techniques (e.g., languageimplementations or analysis techniques).THE ORIGINS OF OBJECT ORIENTATION91the world in software. Object orientation as a programming style isdistinct from any particular object-oriented language implementation.In the first place, object orientation grew up around the need fora descriptive language for use in simulating discrete physical systems.In particular, it emerged from the work of Dahl and Nygaard at theNorwegian Computing Centre through the early and mid-1960s, whichresulted in the Simula languages.11 These ideas were in turn pickedup in the early 1970s by Alan Kay’s research group at Xerox PARC inCalifornia and drove the development of Smalltalk, which was initiallyan experiment in devising a language to teach programming concepts tochildren [Kamin and Samuel 1990].Both Simula and Smalltalk (but Simula in particular) served as explicitinfluences for Bjarne Stroustrup, working at Bell Labs in the early 1980sand looking for a way of introducing what had become known in theliterature as abstract data types into a C-style language, to try to overcomeproblems in writing very large systems.
The specific context was largeprojects at AT&T, including telephone switch software (which typicallywere programs containing millions of lines of code). Coincidentally, anindependent effort to harness the plain syntax and underlying efficiencyof C to an object model was being pursued by Brad Cox and led to theappearance of Objective-C more or less simultaneously with C++.12Just as both C++ and Objective-C set out with an explicit goal ofcreating a better C, so later twists in the story of object orientation haveseen Java claiming a place as a better C++, and C# claiming in turnto be a better Java. James Gosling’s group at Sun started work on whatbecame Java in 1990, addressing the perceived shortcomings of C++ inthe particular context of small, consumer devices such as set-top boxes.Java certainly achieves greater simplicity, greater language uniformityand a purer object model than C++, as well as wider goals of platformindependence, language safety, and tamper resistance.The work at Microsoft to create a better Java began in the late-1990s,as part of the Java-like managed code model for the .NET internet servicesframework.
The result is C#, a rather small increment to Java in languageterms, and a rather larger increment to C++, but one which so far isonly available on the Microsoft platform. (Albeit that makes it a largemarketplace.)As well as this relatively linear evolutionary mainstream, a whole hostof object-oriented languages have sprung up through several decades ofresearch. Some have been shortlived, some have persisted, and almostall have contributed something of interest to the wider object-orientedresearch effort. From Beta to Sather to Eiffel to Dylan to Self to Python toRuby, all have had some following, if only within the research community,1112See the discussion and timeline by Sklenar at http://staff.um.edu.mt/jskl1/talk.html.Stroustrup tells the history in [Stroustrup 1994, p.
175].92INTRODUCTION TO OBJECT ORIENTATIONand one or two have found a more permanent niche. Many other alreadyestablished non-object-oriented languages have adopted object-orientedextensions. Smalltalk style, for example, caught on in the Lisp communityin the 1980s with Common Lisp Object System (CLOS), which becamea model for similar extensions to languages such as Pascal, as well asmore esoteric ones such as Prolog and ML. Similarly, the true inheritorsof the Pascal mantle are the Modula languages, of which Modula-3 isan object-oriented language, and Oberon which again is object-oriented(and, interestingly, is not class-centric).13It is hard to think of a major programming language which has notbeen touched, in some way or another, by object-oriented ideas.4.4 The Key Ideas of Object OrientationThe goal of the original Simula language was to reconcile natural modelsof description (of complex real-world behavior) with computation (specification of algorithms which could compute such complex behavior orcompute with it), to support programmed simulations.
From that startingpoint, the key ideas of object orientation emerged.While traditional computing languages cut the world into algorithmsand data structures, object-oriented languages instead cut the world intoobjects, each of which encapsulates both algorithms (behavior) and data(state). Running an object-oriented program becomes more like runninga physical model of the world.14 This different approach captures anumber of insights, in particular that the real world is more naturallyunderstood as discrete and not continuous (or at any rate that we canbenefit from modeling it that way) and that, in the real world, behaviorcomes packaged with context (context-free behavior is of formal interestonly).A few high-level principles provide the basic modeling tools of objectorientation:• Abstraction hides detail by finding the commonalities between things,so that difference becomes variation• Data hiding hides data inside objects as state• Interfaces, or behavior hiding, expresses public behavior in publicprotocols and hides private behavior.Different object-oriented languages vary in the ways they support theseprinciples, but a small number of mechanisms are almost universal (at13See the official page at www.oberon.ethz.ch.‘A program execution is regarded as a physical model, simulating the behavior ofeither a real or imaginary part of the world.’ [Madsen et al.
1993, p. 16].14THE KEY IDEAS OF OBJECT ORIENTATION93any rate in the mainstream object-oriented languages, including Smalltalk,C++ and Java):• Encapsulation supports data hiding; in class-based mainstream objectoriented languages, classes are the units of encapsulation• Inheritance provides the mechanism for structuring relationshipswithin object-oriented programs and for supporting code-sharing andreuse• Polymorphism (sometimes referred to as dynamic binding), the headline characteristic of object-oriented languages, is the result ofabstraction and the basis for reuse; the mechanisms that enableobjects to display multiple behaviors are superclass (generalization)and subclass (specialization).While a lot of theory has evolved around object orientation, objectoriented ideas are intended to be intuitive.
As Coad and Yourdon put it,quoted in [Madsen et al. 1993], ‘Object-oriented analysis is based uponconcepts that we first learned in kindergarten: objects and attributes,classes and members, wholes and parts’.Object orientation emerged very naturally in the context of computersimulations of physical processes. The purpose of simulating a processis to understand it; but, in order to simulate it, it must be modeledand modeling requires understanding. To break the regression, thinkof modeling as a way of transforming one kind of understanding intoanother kind (information in this respect is like energy or matter: it resistslossless compression). A model reduces a problem in a systematic way torecognizable objects, parts, and the relationships between them, allowinga deeper understanding to emerge from the complex dynamics whicharise in the running system from the interactions between objects.