home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-23 | 48.6 KB | 1,094 lines |
- Newsgroups: comp.object
- Path: sparky!uunet!charon.amdahl.com!netcomsv!netcom.com!objsys
- From: Bob Hathaway <objsys@netcom.com>
- Subject: FAQ (Part 1 of 2)
- Message-ID: <1993Jan23.071036.141@netcom.com>
- Keywords: FAQ
- Sender: objsys@netcom.com (Object Systems)
- Organization: Object Systems
- Date: Sat, 23 Jan 1993 07:10:36 GMT
- Lines: 1082
-
- Hello Netters,
-
- I'm posting this incomplete FAQ (we're still not done arguing yet) because,
- unfortunately, I'm leaving Object Systems (and my ultimate C++ superset) for
- this hot little company doing even more dynamic and profound things in the
- object model. The FAQ will still undergo major revision. Anyway, I should
- be able to pick up from there a little later...
-
- bob
- objsys@netcom.com
-
- P.S. Thanks for the many encouraging letters. They help me to continue
- working on the FAQ whenever I can...
-
-
- COMP.OBJECT FAQ
- Version: -1.0.2 (PRE-DRAFT RELEASE - REQUEST FOR COMMENTS)
- Date: 1/22/1993
-
- Author:
- Bob Hathaway
- Object Systems
- objsys@netcom.com
-
- Anonymous FTP Site for FAQ: YTBA
- Anonymous FTP Site for comp.object: ???
-
- Copyright January 10, 1992 by Bob Hathaway.
- Permission is granted to freely copy and distribute this document but only at
- no cost to others and with the exception of a nominal distribution fee, if
- any. No sale, resale or reprinting is granted without the explicit written
- permission of the author.
-
- Contributors: Stewart Clamen, Mike DeVaney, Paul Johnson, Ronald C. Schultz,
- Bill Kinnersley, Piercarlo Grandi and many others whose names and
- contributions will be added soon.
-
- Objective:
- In the spirit of other FAQs, to provide a simple document to answer the most
- frequently asked and recurring questions and to allow new users to understand
- frequently discussed topics and terms used in comp.object. This should
- bring new comp.object readers and/or writers to at least an introductory
- level of comprehension as soon as possible. Other goals (hopes) are to
- provide a quick and current reference on available systems such as object-
- oriented languages, CASE, OODB and etc. and to provide good references to
- current and relevant texts.
-
- Disclaimer:
- This document does not reflect the opinions of the author's or any
- contributor's companies. There are no explicit or implicit guarantees
- implied by this document.
-
- BASICS:
- What Is an Object?
- What Is Object Encapsulation (or Protection)?
- What Is a Class?
- What Is a Meta-Class?
- What Is Infinite Regress?
- What are MOPs and Reflection?
- What Is Inheritance?
- What Is Multiple Inheritance?
- Does Multiple Inheritance Pose any Additional Difficulties?
- What Is Dynamic Inheritance?
- What Is Shared (Repeated) Inheritance?
- Why use Inheritance?
- Why Don't Some People Like Inheritance?
- What Is Specialization/Generalization/Overriding?
- What Is the Difference Between Object-Based and Object-Oriented?
- Is a Class an Object?
- Is an Object a Class?
- What Is a Method? (and Receiver and Message)
- What Are Multi-Methods?
- Can I use Multi-Methods in C++?
- What Is OOP?
- What Is OOA/OOD (and where can I get what I need on it)?
- Where Did Object-Orientation Come From?
- What Are the Benefits of Object-Orientation?
- What other FAQs are available?
-
- TYPING:
- What Is Polymorphism?
- What Does Polymorphism Boil Down To in Object-Oriented Programming Languages?
- What Is Dynamic Binding?
- Is There a Difference Between Being a Member or Instance of a Class?
- What Is This I Read About ML and Functional Programming Languages?
- What Is the Difference Between Static and Dynamic Typing?
- What Is the Separation Between Type and Class?
- What Are Generics and Templates?
-
- KINDS OF OO:
- What Is the "Classical" Object-Oriented Paradigm?
- What Is the "Delegation/Prototyping" Object-Oriented Paradigm?
- Are There any Others Paradigms?
-
- GENERAL:
- What are the Major Languages in Object-Oriented Programming Today?
- What are Object-Oriented Databases?
- What are Object-Oriented Operating Systems?
- What Are the Current Object-Oriented Methodologies?
- What Is the OMG/ORA/...?
- Why Is Garbage Collection a Good Thing?
-
- COMMONLY ASKED LANGUAGE SPECIFIC QUESTIONS:
- What Is Downcasting?
- What are Virtual Functions?
-
- ANNOTATED BIBLIOGRAPHY
-
- APPENDIXES
- APPENDIX A VIPS
- APPENDIX B Object-Oriented Databases and Vendors
- APPENDIX C Object-Oriented Languages and Vendors
- APPENDIX D Object-Oriented CASE (OOA/D/P Tools) and Vendors
- APPENDIX E Anonymous FTP sites
- APPENDIX F Magazines, Journals and Lewsletters
-
-
- BASICS
- ======
-
- Suggested Readings:
- [Booch 91]
- Others to be added...
-
- What Is an Object?
-
- There are many definitions of an object, such as found in [Booch 91, p77]:
- "An object has state, behavior, and identity; the structure and behavior of
- similar objects are defined in their common class; the terms instance and
- object are interchangeable". This is a "classical languages" definition, as
- defined in [Coplien 92, p280], where "classes play a central role in the
- object model", since they do not in prototyping/delegation languages.
- "The term object was first formally applied in the Simula language, and
- objects typically existed in Simula programs to simulate some aspect of
- reality" [Booch 91, p77]. Other definitions referenced by Booch include
- Smith and Tockey [see Booch 91]: "an object represents an individual,
- identifiable item, unit, or entity, either real or abstract, with a well-
- defined role in the problem domain." and Cox[Ref]: "anything with a crisply
- defined boundary". Booch goes on to describe these definitions in depth.
-
- In symbolic languages, such as Smalltalk and Lisp-based systems, variables are
- loosly bound to objects, and can be viewed as labels referring to objects.
-
- The implementation of objects could be categorized into descriptor-based,
- capability-based, and simple static-based approaches. Descriptor-based
- approaches (e.g. Smalltalk handles) allow symbolic programming, capability-
- based approaches are found in object-oriented databases and operating systems
- (object id's) and simple static approaches are found in languages such
- as C++.
-
- Below is a simple example of statically typed objects from a conventional
- procedural programming point of view intended to show new users one of the
- simplist cases of objects in terms of something they may already be familiar
- with, conventional programming (and BTW, object-oriented programming is
- procedural because of its functional/behavioral interfaces and implementations
- (see methods)):
-
- Simple statically-typed objects can be viewed as instances of a record type,
- whose record fields are called instance variables (Smalltalk) or member data
- (C++). The record (class) may also contain operations which are called
- methods (Smalltalk) or member functions (C++) which are equivalent to a
- function taking an object of the record type, called the receiver, as the
- first parameter. The receiver is called self (Smalltalk) or this (C++).
- Members will denote both instance variables and methods. Inheritance is
- roughly equivalent to a loosly coupled variant record, with derived classes
- as variant parts and with multiple-inheritance concatenating several records
- to serve as a base. Pointers, references and access types are simple examples
- of symbolic programming, where pointer objects are not tightly bound to the
- objects they denote. Since most symbolic languages are statically typeless
- (or just "typeless") but have dynamic types, an untyped pointer (such as void*
- in C++) and an embedded dynamic type scheme must be used in conventional
- languages to fully emulate symbolic programming.
-
- The terms method/member function, instance variable/member data, subclass/
- derived class, parent class/base class, and etc. will be used interchangeably.
- As pointed out in [Stroustrup 91, p197], the base/derived class terminology
- may be preferable to the sub/super-class terminology, and is preferred in
- this document also.
-
- Delegation/prototyping languages have a more flexible kind of object which
- can play the role of classes in classical languages. Since there is no
- separate class construct in these languages, they are referred to as single-
- hierarchy, or 1 Level systems. Objects contain fields, methods and delegates
- (pseudo parents), whereas classical object-oriented languages associate
- method, field and parent definitions with classes (and only associate state,
- and class with objects). Typical 1 Level objects can contain any number of
- fields, methods and parents and any object can be used as a template/exemplar,
- thus performing the classical role of a class. In typical prototyping
- systems, parents (as any other member) can be added dynamically, providing
- dynamic multiple inheritance. It is common in such systems for an object to
- "become" another kind of object by changing its parent. An good example is a
- window becoming an icon, since window and icon objects display different
- behavior. Delegation refers to delegating the search for an attribute to
- a delegate, and is therefore more of a pure message passing mechanism than
- inheritance.
-
- 1 Level systems therefore provide the most flexible and powerful capabilities.
-
-
- What Is Object Encapsulation (or Protection)?
-
- Some languages permit arbitrary access to objects and allow methods to be
- defined outside of a class (as in CLOS, but with voluntary restrictions)
- giving users complete access to objects. However most object-oriented
- languages provide a well defined interface to their objects thru classes.
- C++ has a very general protection mechanism with public, private and protected
- members. Public members (member data and member functions) may be accessed
- from anywhere. A Stack's Push and Pop methods will be public. Private
- members are only accessible from within a class. A Stack's representation,
- such as a list or array, will usually be private. Protected members are
- accessible from within a class and also from within subclasses (also called
- derived classes). A Stack's representation could be declared protected
- allowing subclass access.
-
- For another example, Smalltalk's class instance variables are not accessible
- from outside of their class (they are not only private, but invisible).
- Smalltalk's methods are all public (can be invoked from anywhere), but a
- private specifier indicates methods should not be used from outside of the
- class. All Smalltalk instance variables can be accessed by subclasses (this
- helps with abstract classes and overriding).
-
-
- What Is a Class?
-
- There are many definitions of a class, such as [Booch 91, p93], "a group, set,
- or kind marked by common attributes or a common attribute; a group division,
- distinction, or rating based on quality, degree of competence, or condition"
- and Booch's definition in the context of object-oriented design "A class is a
- set of objects that share a common structure and a common behavior." "A
- single object is simply an instance of a class."
-
- In more pragmatical programming terms, a Class is a specification of structure
- (instance variables), behavior (methods), and inheritance (parents, or
- recursive structure and behavior). As pointed out above, classes can also
- specify access permissions for clients and derived classes.
-
-
- What Is a Meta-Class?
-
- A Meta-Class is a class' class. If a class is an object, then that object
- must have a class (in classical OO anyway). Compilers provide an easy way to
- picture Meta-Classes. Classes must be implemented in some way; perhaps with
- dictionaries for methods, instances, and parents and methods to perform all
- the work of being a class. This can be declared in a class named "Meta-Class".
- The Meta-Class can also provide services to application programs, such as
- returning a set of all methods, instances or parents for review (or even
- modification). In Smalltalk, the situation is more complex. To make this
- easy, refer to the following:
-
- 1 Level System
- All objects can be viewed as classes and all classes can be viewed as
- objects (as in Self). There is no need for Meta-Classes because objects
- describe themselves. Also called "single-hierarchy" systems.
- 2 Level System
- All Objects are instances of a Class but these are not accessible to
- programs (no Meta-Class except for in the compiler and perhaps for type-safe
- linkage, as in C++). Also called "dual-hierarchy" systems.
- 3 Level System
- All objects are instance of a class and all classes are instances of
- Meta-Class. The Meta-Class is a class and is therefore an instance of
- itself (really making this a 3 1/2 Level System). This allows classes to
- be first class objects and therefore classes are available to programs.
- 5 Level System
- What Smalltalk provides. Like a 3 Level System, but there is an extra level
- of specialized Meta-Classes for classes. There is still a Meta-Class as in
- a 3 Level System, but as a class it also has a specialized Meta-Class, the
- "Meta-Class class" and this results in a 5 Level System:
- object
- class
- class class (Smalltalk's Meta-Classes)
- Meta-Class
- Meta-Class class
-
-
- What Is Infinite Regress?
-
- In the authors opinion, a myth. The story goes a class has a Meta-Class,
- which must also have a Meta-Meta-Class, which must also have a
- Meta-Meta-Meta-Class ... The trick is to have a loop at the end, as with a
- Meta-Class pointing to itself, or to have a "Meta-Class - Meta-Class class"
- loop (as in Smalltalk).
-
-
- What Are MOPs and Reflection?
-
- MOP is an acronym for Meta-Object Protocol. This is a system with
- Meta-Classes accessible to users. An introspective protocol provides a read
- only capability (e.g. what is this object's class, give info on this class,
- etc.) and an intercessory protocol provides a write capability which allows
- system modification (e.g. add the following method or instance to this class,
- perform inheritance this way, etc.). Because inheritance can be used to
- perform differential changes, intercessory protocols allow users to not only
- define new frameworks but to specialize existing system frameworks
- differentially without affecting them and their extant objects. Thus, many
- frameworks can interoperate together simultaneously.
-
- "Reflective" systems are systems with MOPs (not to be confused with reflexive
- systems, which often refer to systems implemented in terms of themselves, or
- bootstrapped).
-
-
- What Is Inheritance?
-
- Inheritance is a relationship between classes where one class is the
- parent (or base) class of another. Inheritance can be used as an
- is-a-kind-of relationship or for differential programming. Inheritance
- also doubles for assignment compatibility (see What is the difference
- between Type and Class?).
-
- An example of the is-a-kind-of (is-a can be used synonymously, but is often
- used to show the "object is-a class" instantiation relationship. In classical
- OO, is-a-kind-of is a relationship between classes only) relationship is as
- follows:
-
- Computer
- / | \
- Mainframe Mini Personal
- / \ ... / \
- Data Proc Scientific PC Workstation
-
- Class hierarchies are subjective and usually drawn with the parent class on
- top, but more demanding graphs (as is often the case in [Rumbaugh 91]) often
- allow any topology, with the head of an arrow indicating the parent (base)
- class and the tail indicating the subclass (derived) class.
-
- Differential programming is the use of inheritance to make a small change to
- a class. Creating a subclass to alter a method or to add a method to
- a parent class is an example of differential programming.
-
- A Parent class is called a base class and a subclass is called a derived
- class in C++, these terms are used interchangeably here.
-
-
- What Is Multiple Inheritance?
-
- Multiple Inheritance occurs when a class inherits from more than one parent.
-
-
- Does Multiple Inheritance Pose any Additional Difficulties?
-
- Yes, it does. Any name can be simply resolved to a class member with single
- inheritance by simply accessing the first name encountered for data members
- and for accessing the first signature match (or ambiguity) encountered for
- methods (at least one way, C++ hides some member functions). Since several
- parents can declare a member, which to choose becomes an issue. Eiffel forces
- derived classes to rename parent members that conflict. Self prioritizes
- parents. CLOS merges member "slots" (instance variables) with the same name
- into a single slot. C++ declares an error iff a conflict arises (but a class
- qualifier can be used to explicitly disambiguate).
-
-
- What Is Dynamic Inheritance?
-
- Dynamic inheritance refers to the ability to add, delete, or change parents
- from objects (or classes) at run-time. 1 Level Systems typically provide
- dynamic inheritance. In many systems these parents can be any object; however,
- so objects acting as classes are often "cloned" to provide unshared or unique
- attributes.
-
-
- What Is Shared (Repeated) Inheritance?
-
- Multiple Inheritance brings up the possibility for a class to appear as a
- parent more than once in a class graph (repeated inheritance), and there is
- then a potential to share that class. Only one instance of the class will
- then appear in the graph (as is always the case in CLOS, because all *members*
- with the same name will be shared (receive a single slot) with the greatest
- common subtype as its type. C++ provides an alternative, where only parents
- specified as virtual (virtual bases) are shared within the same class lattice,
- allowing both shared and non-shared occurrences of a parent to coexist. All
- "features" in Eiffel (C++ members) of a repeated parent that are not to be
- shared must be renamed "along an inheritance path", else they are shared by
- default. This allows a finer granularity of control but requires more work
- for parents with many fetaures.
-
-
- Why Use Inheritance?
-
- Inheritance provides for code and structural reuse. In the above Computer
- class diagram, all routines and structure available in class Computer are
- available to all subclasses throughout the diagram. All attributes available
- in Personal computers are also available to all of its subclasses. This kind
- of reuse takes advantage of the is-a-kind-of relationship.
-
- With differential programming, a class does not have to be modified if it is
- close to what's required; a derived class can be created to specialize it.
- This avoids code redundancy, since code would have to be copied and modified
- otherwise.
-
-
- Why Don't Some People Like Inheritance?
-
- Some people complain that inheritance is hierarchical (which is what most
- object-oriented languages provide). They would also like to see more
- operations available (set operations are quite common in specialized systems).
- These are really language dependent features commonly found in object-oriented
- languages which are then associated with the term "inheritance" (although
- they don't need to be). Some don't like the coupling of classes (as in Jade),
- but in the author's opinion many of their complaints are easily answered.
- In systems that provide inheritance, inheritance provides a simple and elegant
- way to reuse code and to model the real world in a meaningful way.
-
- Others complain multiple inheritance is too complicated because it brings up
- the issues of shared bases and member conflict resolution. But most modern
- systems support Multiple Inheritance by employing semantic resolution
- strategies, and many consider MI to be highly desirable.
-
-
- What Is Specialization/Generalization/Overriding?
-
- To create a subclass is specialization, to factor out common parts of
- derived classes into a common base (or parent) is generalization [Booch 91,
- p56]. Overriding is the term used in Smalltalk and C++ for redefining a
- (virtual in Simula and C++) method in a derived class, thus providing
- specialized behavior. All routines in Smalltalk and Eiffel are overridable
- (although in Eiffel they must be "redefined" in a derived class). Whenever
- a method is invoked on an object of the base class, the derived class method
- is executed overriding the base class method, if any. Overriding in Simula
- is a combination of overloading and multi-methods because parameters do not
- have to be declared.
-
-
- What Is the Difference Between Object-Based and Object-Oriented?
-
- Object-Based Programming usually refers to objects without inheritance
- [Cardelli 85] and hence without polymorphism, as in '83 Ada and Modula-2.
- Proposed '93 Ada and Modula-3; however, support inheritance and polymorphism.
- [Cardelli 85, p481] state "that a language is object-oriented if and only if
- it satisfies the following requirements:
- - It supports objects that are data abstractions with an interface of named
- operations and a hidden local state.
- - Objects have an associated type [class].
- - Types [classes] may inherit attributes from supertypes [superclasses].
-
- These definitions are also found in [Booch 91, Ch2]. A more modern definition
- includes single hierarchy languages and perhaps object id's for unique objects.
- Object id's support the more modern notion of relocatable, persistent and
- distributed objects that can even migrate across machines.
-
-
- Is a Class an Object?
-
- In C++ no, because C++ classes are not instances of an accessible class (a
- Meta-Class) and because C++ classes are not accessible to programs. Classes
- are objects in 3 Level Systems and above because classes have Meta-Classes
- and can therefore be accessed in the same way as any other object. But
- classes play a dual role, because objects can only be declared to be instances
- of a class. In 1 Level (single hierarchy) systems, all classes are objects,
- so to speak.
-
-
- Is an Object a Class?
-
- In a Level 3 System and above yes, but only instances of a Meta-Class
- are Classes. Instances of a Class (ordinary objects) are not classes.
- However, all objects may be classes in single hierarchy systems, since any
- object may act as a class (provide object instantiation). If done directly,
- this object may be shared among many class graphs. To get the effect of a
- typical parent (e.g. if instance variables are shared), the class object
- is usually cloned and then made a parent.
-
-
- What Is a Method? (and Receiver and Message)
-
- A method is a function or procedure which is defined in a class and can
- access the internal state of an object of that class to perform some
- operation. It can be thought of as a procedure with the first parameter
- as the object to work on. This object is called the receiver, which is the
- object the method operates on. The following are some common notations for
- invoking a method, and this invocation is called a message (or message
- passing):
-
- receiver.message_name(a1, a2, a3)
- receiver message_name: a1 parm1: a2 parm3: a3
-
- Selector would be another good choice for message_name in the above examples,
- although the keywords (or formal parameter names, like named parameters) are
- considered part of the selector in Smalltalk.
-
- A method implements behavior, which is defined by [Booch 91, p80]:
-
- Behavior is how an object acts and reacts, in terms of its state changes
- and message passing.
-
-
- What Are Multi-Methods?
-
- In Multi-Methods all parameters are used in the selection of a method
- (multiple-polymorphism). The name comes from CLOS, a language with both
- static and dynamic typing. CLOS does not distinguish a receiver and
- typically associates a method with the classes of all specialized parameters.
- While the notion of multi-methods originally comes from such loosly coupled
- methods and classes, the idea also applies to classical object-oriented
- languages. Statically-typed languages such as C++ place restrictions on
- parameters, so that overriding methods must have identical signatures with the
- methods they substitute. If this restriction is dropped, a Multi-Method
- capability is available. With Multi-Methods, a single overridable function
- declared in a base class may have several functions overriding it in a derived
- class differentiated only by their formal argument types. Therefore multi-
- methods require both static and dynamic typing, because no formal argument
- differentiation is possible without static types and no actual argument
- differentiation would be possible without dynamic types.
-
- There is some concern about the efficiency of run-time method selection
- as can occur with multi-methods. However, static analysis optimizations are
- commonly available in the literature, potentially providing a single static
- selection in certain cases. But coupling the two cases of unknown selectors
- (as found in CLOS and other dynamic languages) and several possible known
- selectors together with the undecidability of dynamic types at run-time
- renders dynamic typing and run-time selection (or checking) as unavoidable in
- the general case [a point often mistaken in comp.object].
-
-
- Can I use Multi-Methods in C++?
-
- Yes, but you'll need to embed a dynamic typing scheme to do it. With
- dynamic types in place, an overriding method in a derived class can explicitly
- check argument types in a switch statement and invoke the desired method
- [Coplien 92]. Future FAQs should contain more detail.
-
-
- What is OOP?
-
- OOP stands for Object-Oriented Programming, the usual programming/hacking and
- etc. most programmers think of.
-
-
- What Is OOA/OOD (and where can I get what I need on it)?
-
- See also "What Are the Current Object-Oriented Methodologies?", the
- Annotated Bibliography, and APPENDIX D Object-Oriented CASE (OOA/D/P Tools)
- and Vendors.
-
- OOA and OOD stand for Object-Oriented Analysis and Object-Oriented Design,
- respectively. To generalize (since these terms differ between systems),
- OOA analyzes the problem domain in terms of objects and classes, while OOD
- reflects the system to be built in the same terms. The usual progression is
- from OOA to OOD to OOP. Since classes and objects are used in all phases,
- the process is often referred to as seamless, meaning there is no conceptual
- or even actual gap or hiatus between them as is often the case in other
- software development methodologies.
-
- OOA and OOD differ from OOP in that the notations are graphical instead of
- the usual textual declarative form. This allows easier visualization and
- makes dependencies more explicit. For example, an association is an annotated
- and labeled line connecting classes in an OOA or OOD diagram, but is often
- a pointer declaration (or an instance of another class) in OOP ([Rumbaugh 91]
- explicitly addresses the implementation of associations in several sections).
-
- An OO problem domain has many realizations, or differing OOAs. An OOA has
- many realizations, or differing OODs, but a similar notation is often used
- for the two. An OOD also has many realizations, or differing OOPs, but allows
- a selection from among various languages for implementation (choosing the best
- language to implement the design). But some, such as Bjarne Strostrup, don't
- like OOA and OOD getting too far from OOP (implementation independent), for
- fear that great discrepancies could occur between OOD and OOP by losing sight
- of the implementation language, which in some cases is predetermined.
-
-
- Where Did Object-Orientation Come From?
-
- Simula was the first object-oriented language because it provided facilities
- such as classes, inheritance, and dynamic typing back in 1967 (in addition to
- its Algol-60 subset). Simula 1 was a simulation language, and the later
- general-purpose language Simula 67 is now referred to as simply Simula.
- Smalltalk was the next major contributor which included classes, inheritance,
- a nice environment and a powerful dynamic typing mechanism.
-
-
- What Are the Benefits of Object-Orientation?
-
- Reuse, quality, an emphasis on modeling the real world (or a "stronger
- equivalence" with the RW than other methodologies), a consistent and seamless
- OOA/OOD/OOP package, naturalness (our "object concept") and etc.
-
-
- What Other FAQs Are Available?
-
- There are also FAQ's for comp.lang.c++, comp.lang.eiffel, and comp.lang.clos
- (more should be added soon).
-
-
- TYPING
- ======
-
- References
- [Booch 91] Small Section on Typing.
- [Cardelli 85] Discussion on Object-Oriented Typing.
- [Kim 89, ch1] Discussion on Some Research Topics.
-
- What Is Polymorphism?
-
- For a Brief Answer:
- Polymorphism is the ability of an object to assume or become many different
- forms of object and for these various forms to exhibit explicit phenotype-
- like expression. Inheritance (or delegation) specifies slightly different or
- additional structure or behavior for an object, and these more specific or
- additional attributes of an object of a base class when assuming or becoming
- an object of a derived class characterizes object-oriented polymorphism. This
- is a special case of parametric polymorphism, which allows an object to assume
- or become any object (possibly satisfying some implicit or explicit type
- constraints (parametric type), or a common structure) and not just objects of
- derived classes.
-
- For a More Detailed Answer:
- "Poly" means "many" and "morph" means "form". The homograph polymorphism has
- many uses in the sciences, all referring to objects that can take on or assume
- many different forms. Computer Science refers back to Strachey's original
- definitions of polymorphism, as divided into two major forms, parametric and
- ad-hoc. "Parametric polymorphism is obtained when a function works uniformly
- on a range of types; these types normally exhibit some common structure. Ad-
- hoc polymorphism is obtained when a function works, or appears to work, on
- several different types (which may not exhibit a common structure) and may
- behave in unrelated ways for each type." Parametric polymorphism is also
- referred to as "true" polymorphism, whereas ad-hoc polymorphism isn't.
- These definitions are functional in nature, whereas the brief answer
- is a more object-oriented definition.
-
- Another definition of polymorphism is proposed by Cardelli and Wegner;
- however, they tie parametric polymorphism to static typing which leads
- to generics, a static implementation technique. The original definitions
- do not have any such restriction and so the author feels their definitions
- are not as general as the original ones. [Cardelli 85] does; however, give
- a good discussion on object-orientation and on the separation between type
- and class, as is typically found in the modern formal type systems based on
- the typed lambda calculus notation.
-
- Inclusion polymorphism can refer to subtyping, or having at least as much
- or more than is required. Since derived classes inherit structure and
- behavior from base classes, such inheritance is an example of inclusion
- polymorphism with respect to representation. An example of inclusion
- polymorphism with respect to assignment (and initialization) occurs when
- object types may be specified statically and assignment is based on actual
- object membership in that type (often of the CLOS is-a-member-of form in OO).
- Emerald is an example of an object-oriented language that uses inclusion
- polymorphism to cover the general parametrically polymorphic case, since
- Emerald has a separation between type and class. They refer to this as
- "best-fitting" types.
-
-
- What Does Polymorphism Boil Down to in Object-Oriented Programming Languages?
-
- In C++, virtual functions provide polymorphism. This is because a formal
- object (pointer or reference (or such parameter)) is polymorphically assignment
- compatible with any derived class. Is this polymorphism in itself? Objects
- can take on objects of different forms (the derived classes), but of what use
- is it? To make any difference, the differing forms must have some effect. In
- dynamically typed languages, actual objects are passed messages and will
- respond in whatever way the actual object has defined (usually starting
- from its most derived class and working its way up). But for static objects,
- a virtual function is invoked. This is the stored method from the derived
- class that overrode the virtual method from its base class, providing
- specialized behavior for the formal object; and hence, polymorphism.
-
-
- What Is Dynamic Binding?
-
- Dynamic binding has two forms, static and dynamic. Static dynamic binding
- is found in statically-typed languages such as C++, in virtual functions.
- When a class with virtual functions is used, it is not known which
- function will be called at run-time since a derived class may override
- the function, in which case the overriding function must be called.
- Statically determining all possibilities of usage is undecidable. When
- the complete program is compiled, all such functions are resolved (statically)
- for actual objects. Formal object usage must have a consistent way of accessing
- these functions, as achieved thru vtables of function pointers in the actual
- objects (C++) or equivalent, providing statically-typed dynamic binding.
-
- The run-time selection of messages is another case of dynamic binding, meaning
- lookup is performed (bound) at run-time (dynamically). Various optimizations
- exist for dynamic lookup to increase efficiency.
-
-
- Is There a Difference Between Being a Member or Instance of a Class?
-
- Yes (but be careful of context). To use C++ terminology, an actual object
- is defined to be an instance of exactly one class (in classical OO), called
- its most derived class. That actual object is called the complete object.
- An actual object is a member of (CLOS terminology) several classes, including
- all of the classes its declared (or most derived) class inherits from. With
- static typing, if a formal object is made to refer to an actual object, that
- actual object must be a member of the formal object's class.
-
- This provides a good example of differing definitions among object-oriented
- languages, since a member is defined as above in CLOS, but a member of a class
- is one of its instance variables in C++.
-
-
- What Is the Difference Between Static and Dynamic Typing?
-
- Static typing means that there is type information used at compile-time.
- It is also often used to refer to languages that are strongly typed, that
- is no type information is needed at run-time. Static typing is therefore
- more efficient and reliable, but loses power. Typical restrictions include
- only allowing a common set of base class functions (or any common functions
- for the more general parametric polymorphic case) to be available on formal
- objects and a lack of multi-methods; both of which are overcome with dynamic
- typing.
-
- Many languages provide dynamic typing: Smalltalk, Self, Objective-C, and etc.
- A limited dynamic typing scheme, called RTTI (Run Time Type Identification),
- is even being considered for the C++ standard.
-
-
- What Is This I Hear About ML and Functional Programming Languages?
-
- ML, Milner's Language, is a functional programming language with a statically
- typed polymorphic type system. We've already discussed why static typing is
- weaker than dynamic typing and the same applies to ML. ML doesn't use
- inheritance for polymorphism; unlike OO languages, but provides a kind
- of inclusion polymorphism by allowing assignment compatibility for any object
- that can *at least* satisfy the required type constraints of a formal object,
- so no inheritance is required. This is "true" or "pure" statically (or
- strongly) *checked* parametric polymorphism, by Strachey's definitions.
-
- Smalltalk is an example of a dynamically-typed symbolic language which does
- not check types during assignment (and hence for parameters) and therefore
- provides parametric polymorphism without static constraints.
-
-
- What Is the Separation Between Type and Class?
-
- In many OO languages, classes are used for assignment compatibility. This
- forces all matching objects to inherit (transitively) from any formal object's
- class. This insures that all operations to be performed on any formal object
- are satisfied by any matching object (and ultimately by any actual object).
-
- By separating type and class (just one way of putting it), any matching object
- must satisfy the operations or type constraints of a formal object, but do not
- have to do so by an inheritance relation. There are several ways of
- implementing inheritance on the "typing" side, one is to simply allow reuse of
- parent types and require all operations in the formal type graph to be present
- in any actual object. Inheritance on the representation side is what most
- object-oriented programmers think of, because representation classes usually
- double for parametric-style typing.
-
- Formal type systems (such as found in ML), Emerald/Jade and trellis/Owl all
- possess a separation between type and class.
-
-
- What are Generics and Templates?
-
- Generics (or Templates in C++) refer to the ability to parameterize types
- and functions with types. This is useful for parameterized classes and
- polymorphic functions in statically typed languages such as Ada, C++, Eiffel,
- and etc. Generics are orthogonal to inheritance, since types (and classes)
- may be generically parameterized. Generics provide for reusability in
- programming languages. An example is a Stack with a generically
- parameterized base type. This allows a single Stack class to provide
- many strongly checked instantiations such as a Stack of ints, a Stack
- of any fundamental or user defined type, or even a Stack of Stacks of ....
-
- While generics have many advantages, limitations include its static nature
- (which is an advantage for strong typechecking but a disadvantage for run-time
- flexibility which either isn't present or potentially causes dynamic
- compilation (leading to a time/space/static efficiency tradeoff)), and sources
- are like inlines and create source code dependencies and usually expand code
- size (unlike a single-body parametrically polymorphic implementation found in
- dynamically-typed languages). Generics are also a special static case of
- type variables.
-
- All functions are generic in statically-typed parametrically-polymorphic
- languages. One such popular language is ML, in which all functions are
- implicitly generically instantiated.
-
-
- KINDS OF OO:
- ============
-
- References
- [Coplien 92] Covers C++, symbolic, exemplar (single-hierarchy), etc.
- [Kim 89] Covers many OO systems.
-
-
- What Is the "Classical" Object-Oriented Paradigm?
-
- This refers to the usual class and object model. Its any 2+ level system
- as described above under Meta-Classes [Coplien 92].
-
-
- What Is the "Delegation/Prototyping" Object-Oriented Paradigm?
-
- This is the 1 Level System as Described under Meta-Classes. Delegation
- refers to the delegating of responsibility and can be applied to
- inheritance. When a derived class does not have a desired attribute,
- it "delegates" responsibility to one of its base classes. In delegation
- systems, each object has a delegate list instead of a parent list. Thus,
- delegation's original intention was not for inheritance but was for
- message passing systems where an object could delegate responsibility of
- a message it couldn't handle to objects who potentially could (its delegates).
- Any object can be added to the delegate list, giving dynamic inheritance (of
- a sort). Typically, delegation and prototyping languages also have "part
- inheritance" in which fields and methods can be added and deleted from
- objects. This makes for easy "prototyping", which allows for objects to be
- constructed piece by piece at run-time.
-
-
- Are There any Others Paradigms?
-
- There are many alternatives in OO. Emerald/Jade provides one, where
- inheritance is replaced with a roughly equivalent form where reuse occurs at a
- finer degree of granularity, the method and instance variables.
-
- CLOS has a looser coupling of methods to classes and doesn't distinguish a
- receiver, but modules can help make up the difference.
-
-
- GENERAL
- =======
-
- References to be added..
-
- What Are the Major Languages in Object-Oriented Programming Today?
-
- Statically-Typed:
- C++
- Eiffel
-
- Dynamically-Typed:
- Smalltalk
- Self
- Objective-C
-
- Both:
- CLOS
-
-
- What Are Object-Oriented Databases?
-
- Object-Oriented Databases are databases that support objects and classes.
- They are different from the more traditional relational databases because
- they allow structured subobjects, each object has its own identity, or
- object-id (as opposed to a purely value-oriented approach) and because of
- support for methods and inheritance. It is also possible to provide
- relational operations on an object-oriented database. These databases allow
- all the benefits of object-orientation, as well as the ability to have a
- strong equivalence with object-oriented programs, an equivalence that would be
- lost if an alternative were chosen, such as a relational database.
-
- Another way of looking at Object-Oriented Databases is as a persistent object
- store with a DBMS.
-
-
- What Are Object-Oriented Operating Systems?
-
- Object-Oriented Operating Systems support objects all the way down to
- to the machine. They are almost always distributed systems, allowing
- objects to be passed freely between machines. They are capability-based
- since objects, and hence system resources, can only be accessed if a
- capability to them is available to programs.
-
-
- What Are the Current Object-Oriented Methodologies?
-
- An excellent review of available Methodologies recently appeared in CACM/
- September 1992/Vol.35, No.9, pp35, "A Research Typology for Object-Oriented
- Analysis and Design". The Process and Representation Methodologies/Notations
- surveyed are:
- Alabiso
- Bailin
- Booch
- Coad/Yourdon
- Gorman and Choobineh
- Iivari
- Kappel
- Lieberherr et al.
- Meyer
- Rumbaugh et al.
- Shlaer and Mellor
- Wirfs-Brock et al.
-
-
- What Is the OMG/ORA/...?
-
- Contact Person: To be added
- FTP Site: To be added
-
- The Object Management Group (OMG) is an international software industry
- consortium with two primary aims:
-
- (*) promotion of the object-oriented approach to software engineering
- in general, and
-
- (*) development of command models and a common interface for the development
- and use of large-scale distributed applications (open distributed
- processing) using object-oriented methodology.
-
- In late 1990 the OMG published its Object Management Architecture
- (OMA) Guide document. This document outlines a single terminology for
- object-oriented languages, systems, databases and application
- frameworks; an abstract framework for object-oriented systems; a set
- of both technical and architectural goals; and an architecture
- (reference model) for distributed applications using object-oriented
- techniques. To fill out this reference model, four areas of
- standardization have been identified:
-
- 1) the Object Request Broker, or key communications element, for
- handling distribution of messages between application objects in
- a highly interoperable manner;
-
- 2) the Object Model, or single design-portability abstract model for
- communicating with OMG-conforming object-oriented systems;
-
- 3) the Object Services, which will provide the main functions for
- realising basic object functionality using the Object Request Broker -
- the logical modeling and physical storage of objects; and
-
- 4) the Common Facilities will comprise facilities which are useful in
- many application domains and which will be made available through OMA
- compliant class interfaces.
-
-
- Why Is Garbage Collection a Good Thing?
-
- From: Paul Johnson (paj@gec-mrc.co.uk)
-
- Garbage collection (GC) is a facility in the run-time system
- associated with a language which will automatically reclaim objects
- which are no longer used. OO Languages which require garbage
- collection include Eiffel, Smalltalk and CLOS. C and C++ can have
- garbage collection retrofitted (see [3] below). [Ada has switchable GC,
- too -bob]
-
- Without GC programmers must explicitly deallocate dynamic storage when
- it is no longer needed (in C this is done by a call to free(3)).
- There are a number of problems with this:
-
- 1: Bugs due to errors in storage deallocation are very hard to find,
- although products are available which can help.
-
- 2: In some circumstances the decision about whether to deallocate
- storage cannot be made by the programmer. Drawing editors and
- interpreters often suffer from this. The usual result is that the
- programmer has to write an application-specific garbage collector.
-
- 3: An object which is responsible for deallocating storage must be
- certain that no other object still needs that storage. Thus many
- modules must co-operate closely. This leads to a tight binding
- between supposedly independent modules.
-
- 4: Libraries with different deallocation strategies are often
- incompatible, hindering reuse.
-
- 5: In order to avoid problems 3 and 4, programmers may end up copying
- and comparing whole objects rather than just references. This is a
- particular problem with temporary values produced by C++ overloaded
- operators.
-
- 6: Because keeping track of storage is extra work, programmers often
- resort to statically allocated arrays. This in turn leads to
- arbitrary restrictions on input data which can cause failure when
- the assumptions behind the chosen limits no longer apply. For
- instance many C compilers limit expression nesting, identifier
- length, include file nesting and macro stack depth. This causes
- problems for programs that generate C.
-
- One partial solution to a lack of GC is reference counting. In this
- scheme each object keeps a count of references to it. When this count
- drops to zero the object is automatically deallocated. However this
- is inefficient (swapping two references will result in three
- decrements, three increments and six comparisons) and cannot reclaim
- circular data structures. Two systems that use a reference count GC
- are the Interviews C++ graphics library and the Unix file system (the
- link count).
-
- Opponents of GC reply that it introduces an overhead which is
- unacceptable in some applications. However the overhead of manual
- storage deallocation is probably as high as GC. GC algorithms are
- also available with good real-time behaviour.
-
- Further Reading:
-
- [1] "Object-Oriented Software Construction" by Meyer puts the argument
- for GC.
-
- [2] "Uniprocessor Garbage Collection Techniques" in the proceedings of
- the "1992 International Workshop on Memory Management" in the
- Springer-Verlag Lecture Notes in Computer Science series. This is an
- excellent summary of the state of the art in GC algorithms.
-
- [3] "Garbage Collection in an Uncooperative Environment" by Boehm and
- Weiser. Software --- Practise and Experience vol 18(9), pp 807-820.
- Sept 1988. This describes GC in C and C++.
-
-
-
- COMMONLY ASKED LANGUAGE SPECIFIC QUESTIONS
- ==========================================
-
- What is Downcasting?
-
- Downcasting the term used in C++ for casting a pointer or reference to a
- base class to a derived class. This should usually be checked with an
- embedded dynamic typing scheme if such a scheme is not present in the
- language, such as with a typecase (Modula-3) or inspect (Simula) construct.
- In C++, it is even possible to use conversion functions to perform some
- checks.
-
-
- What are Virtual Functions?
-
- Look under "Dynamic Binding" and "Polymorphism".
-
-
- ANNOTATED BIBLIOGRAPHY
-
- [Booch 87] Grady Booch. Software Engineering with Ada. 2nd Ed. Benjamin
- Cummings.
- [Booch 87] Grady Booch. Software Componenets With Ada, Structures, Tools,
- and Subsystems. Benjamin Cummings.
-
- Booch in his early years. Mostly object-based programming with Ada.
-
- [Booch 91] Booch, Grady. Object-Oriented Design With Applications.
-
- The often referred to book on OOD. Offers design notation and methodology.
- Brief coverage of OOA and elaborate OOD/P coverage in the applications.
- Good on basic principles and has case studies in Smalltalk, Object Pascal,
- C++, CLOS and Ada.
-
- Also contains an *elaborate* classified bibliography on many areas of OO.
-
- [Cardelli 85] L. Cardelli and P. Wegner. On Understanding Types, Data
- Abstraction, and Polymorphism. ACM Computing Surveys vol. 17 (4).
-
- Long article on Object-Oriented Types, Data Abstraction and Polymorphism.
- Formal coverage with a type system analysis model as well.
-
- [Coplien 92] James O. Coplien. Advanced C++ Programming Styles and Idioms.
- Addison Wesley.
-
- Covers advanced C++ programming.
-
- [Cox 87] Cox, Brad J. Object-Oriented Programming, An Evolutionary Approach.
- Addison Wesley.
-
- The original book on Objective-C. Coverage on object-oriented design and
- programming. Also covers Objective-C implementation, even into object code.
-
- Emerald/Jade [Entry To Be Completed]
-
- The original articles on Emerald and Jade. OO languages without
- inheritance but with abstract types and static polymorphism. Also
- designed for distributed programming and reuse.
-
- [Goldberg 83], Adele Goldger and David Robson. Smalltalk-80 The Language and
- Its Implementation. Addison Wesley.
-
- The original book on Smalltalk. Covers implementation.
-
- [Kim 89] Won Kim and Frederick Lochovsky Editors. Object-Oriented Concepts,
- Applications, and Databases.
-
- Collection of articles on advanced OO and research systems.
-
- [Meyer 88] Meyer, Bertrand. Object-Oriented Software Construction. Prentice
- Hall. [Is there a new edition out?]
-
- The original book on Eiffel. Coverage on object-oriented design and
- programming.
-
-
- [Rumbaugh 91] Rumbaugh James, et al. Object-Oriented Modeling and Design.
- Prentice Hall.
-
- The often referred to book on OOA/OOD. Introduces the "Object Modeling
- Technique (OMT) OOA/D notation and methodology. Has case studies.
-
- [Stroustrup 91] Ellis, M.A., Stroustrup. The Annotated C++ Reference Manual.
- Addison Wesley.
-
- The ARM; the original and definitive book on C++. Serves as the ANSI
- base document for C++. Also covers C++ implementation.
-
- [Ungar 87] D. Ungar and R.B. Smith. The Self Papers. [Entry To Be Completed]
-
- The documents on Self; a delegation/prototyping language. Also covers
- Self implementation and optimization.
-
-
-
-
-