This action might not be possible to undo. Are you sure you want to continue?
By Edward V. Berard (The Object Agency, Inc.)
• • •
How People Understand Technology How People Approach Object-Oriented Technology Object-Oriented Terms and Concepts o Objects o Classes, Metaclasses, Parameterized Classes, and Exemplars o Black Boxes and Interfaces o Aggregation o Specialization and Inheritance o Abstract Classes o Operations o Constants o Exceptions o Object Coupling and Object Cohesion o Systems of Objects
How People Understand Technology
There is an old story of how several blind men set out to understand what an elephant was by examining a live specimen. Each of them explored a different part of the elephant's body. One blind man, falling against the elephant's side, proclaimed that an elephant must be very much like a wall. Another, grasping the elephant's ear, decided that an elephant must closely resemble a leaf. One grabbed the elephant's tail and determined that elephants must resemble ropes. Yet another felt the elephant's leg and came away convinced that elephants are very much like trees. Still another held the elephant's trunk and exclaimed that elephants had much in common with snakes.
While there was at least a grain of truth in each blind man's observation, none of them had a complete and accurate understanding of just what an elephant is. We can imagine the many animated debates that these blind men had when they compared notes -- each sure that the others must be wrong.
For example. How People Approach Object-Oriented Technology Object-oriented technology is both immense and far-reaching. the same breakfast item might be referred to as a pancake.unless a person studying the facet begins to think that he or she has somehow acquired a good grasp of the entire technology. dynamic and static relationships among these items could also be described in object-oriented terms. and even the "recipes" (proportional combinations) of the chemicals used to create the various plastics could all be described in object-oriented terms. although the terms were borrowed from a non-computer-software perspective. To truly understand a technology. End users of computer systems and computer-based systems notice the effects of object-oriented technology in the form of increasingly easy-to-use software applications and operating systems and in more flexible services being provided by such industries as banking. this variation in . terms and definitions will vary slightly. Many of the terms commonly used in object-oriented technology were originally used to describe object-oriented programming (coding) concepts. Even in technical arenas. and cable television. they were first used extensively to describe concepts embodied in object-oriented programming languages. There is nothing wrong with this -. The task is further complicated by the unfortunate errors contained in many discussions. or a hot cake. people studying technology are like the blind men in our story. object-oriented technology encompasses object-oriented programming languages. these terms are quite useful even if one never intends to write any software at all. management of object-oriented projects. and Eiffel. an individual must be able to recognize valid patterns. Even if an individual can assimilate a large quantity of material and easily identify any errors. in different parts of the United States. It is very common to focus intently on one facet of one aspect of a technology while ignoring the vast breadth of the same technology. Finally. an industrial modeler could create an object-oriented model of a plastics manufacturing facility. we will provide the reader with working definitions for object-oriented terms and concepts that are necessary for a reader to acquire a basic understanding of objectoriented technology. plastic parts. and to easily spot invalid patterns. To acquire an in-depth understanding of a technology requires a great deal of research. there is still the process of analyzing what has been assimilated. Depending on who you are talking to. For the software engineer. The sheer bulk of material that must be examined is daunting. object-oriented computer hardware. C++. telecommunications. among others. that there is some confusion regarding object-oriented terms and concepts. and object-oriented computer aided software engineering. In this article. This is normal. Further. therefore.Often. Molding machines. object-oriented development methodologies. such as Smalltalk. a griddle cake. However. It is not surprising. Specifically. keep in mind that there is no one ultimate set of definitions for object-oriented terms and concepts. a flapjack.
the state of a bank account object would include the current balance. volumes. Classes. whereas the (internal) state of the message object remains unchanged. the state of a clock object would be the current time. a complete description of the state might be very complex. documents.. molecules. It is not uncommon to hear people talk about the "state information" associated with a particular object. i. it is possible for some objects to change their own state. a chief executive officer could view employees. the state of an object will not change unless something outside of the object requests the object to change its state. and temperatures would all be objects a chemist might consider in creating an object-oriented simulation of a chemical reaction. documents. or a set of circumstances describing the object. and benefits packages as objects. For example. A list of names does not spontaneously add new names to itself. Indeed. human beings. software. doors. We also think of the state of an object as something that is internal to an object. That is. and check boxes as objects. For example. buildings. and the current fuel level as objects.terminology is common. Parameterized Classes. An automotive engineer would see tires. If we were modeling a business process." (Objects with life are sometimes also called "active objects" or "actors. the state of an electric light bulb would be "on" or "off. Atoms. and Exemplars There are two broad categories of objects: classes and instances. However. when we use objects to model real world or imagined situations. If an object is capable of spontaneously changing its own state. Finally. queues. For purposes of modeling his or her company. the (internal) state of the mailbox object is changed. nor would we expect it to spontaneously delete names from itself." For complex objects like a human being or an automobile. windows. Object-Oriented Terms and Concepts Objects Objects are the physical and conceptual things we find in the universe around us. Hardware. we would recognize that salespeople and customers were also objects with life. Objects are thought of as having state. many objects are passive (static). we refer to it as an "object with life. Fortunately. and even concepts are all examples of objects. Users of object-oriented technology usually think of classes as containing the information necessary to create instances. Metaclasses.") Clocks and timers are common examples of objects with life. engines. The state of an object is the condition of the object. There are three commonly used (and different) views on the definition for "class": . a software engineer would consider stacks. if we place a message in a mailbox. top speed. we typically restrict the possible states of the objects to only those that are relevant to our models. Sometimes people think of objects as being strictly static. divisions. the structure and capabilities of an instance is determined by its corresponding class. A chemist might use the terms "valance" and "oxidation state" to identify the same concept.e.
" A non-class instance is an instance of a class. we must supply the required parameters. but is itself not a class. or a class that is neither a metaclass nor a parameterized class. An instance of a metaclass. A metaclass is a class whose instances themselves are classes. for example." Instantiation has two common meanings: • • as a verb. be used to create instances -." A class is a thing that consists of both a pattern and a mechanism for creating items based on that pattern. a parameterized class can be viewed as a "fill in the blanks" version of a class. we will use the term "class" to mean metaclass. an instantiation is an instance of a class. . we will use the definition of a "class an `instance factory. This is the "class as an `instance factory'" view. instances are the individual items that are "manufactured" (created) using the class's creation mechanism. we can use its creation mechanisms to create instances. Said another way. In effect.although these instances may or may not themselves be classes. The instance creation mechanism of this class can. or blueprint for a category of structurally identical items. parameterized class. In this article. This means when we use the instance creation mechanism in a metaclass. Once we have a non-parameterized class. we will occasionally refer to "non-class instances. the instances are the "cookies.'" We should note that it is possible for an instance of a class to also be a class. and as a noun. in turn. One cannot directly use the instance creation mechanism of a parameterized class. The items created using the class are called instances. First. Further. instantiation is the process of creating an instance of a class. the class is the set of all instances of that pattern.• • A class is a pattern. In this article. the instance created will itself be a class. We will make a distinction only when it is necessary to do so. • In this article. resulting in the creation of a non-parameterized class. we will sometimes refer to "instantiation. As you might guess. template. A parameterized class is a template for a class wherein specific items have been identified as being required to create nonparameterized classes based on the template. A class is the set of all items created using a specific pattern. A concept very similar to the metaclass is the parameterized class. This is often referred to as the "class as a `cookie cutter'" view. would not be a non-class instance.
) In class-based object-oriented systems. We will only distinguish between the two when needed. The consumers (users) of an object are denied knowledge of the inner workings of the object. only classes can provide an inheritance interface. they have a difficulty attempting to resolve the "problems" these concepts introduce. For these people. designer. (We will discuss inheritance and specialization later in this chapter. This is the interface that is accessible only by direct specializations of the object. possible for objects to be composed of other objects.Some people restrict the use of the term "object" to instances of classes." Specifically. A monolithic object is an object that has no externally-discernible structure. the parameter interface defines the parameters that must be supplied to create an instance of the parameterized class. a day object. classes are not objects.. Black Boxes and Interfaces Objects are "black boxes. In the case of parameterized classes. can be thought of as containing many name objects. In object-oriented systems. is a class that is an instance of a metaclass an object -. when these people are confronted with the concepts of metaclasses and parameterized classes. Those outside of a monolithic object cannot directly interact with any (real or imagined) objects within the monolithic object. it is only the producer (creator. A list of names object. For example. the "parameter" interface. Another way of saying that an item is in the public interface of an object is to say that the object "exports" that item. Aggregation is either: • • the process of creating a new object from two or more other objects. a monolithic object does not appear to have been constructed from two or more other objects. a monolithic object can only be treated as a cohesive whole. as with the parameters in a parameterized class). the underlying implementations of objects are hidden from those that use the object. the "inheritance" interface. or an object that is composed of two or more other objects. Similarly. for example. . we will use the term "object" to refer to both classes and their instances. For example.g. when an object requires information from outside of itself (e. A radio button in a graphical user interface (GUI) is an example of a monolithic object. we can say that the object needs to "import" that information. of course. and must deal with an object via one of its three distinct interfaces: • • • the "public" interface. or builder) of an object that knows the details about the internal construction of that object. and a year object. Specifically. However. Said another way.even though it is itself a class? In this article. a date object could be fashioned from a month object. This is the interface that is open (visible) to everybody. Aggregation It is.
Composite objects meet one or both of the following criteria: • • the state of a composite object is directly affected by the presence or absence of one or more of its component objects. a day object. and a year object) is a heterogeneous composite object. and/or the component objects can be directly referenced via the public interface of their corresponding composite object. another object. For example. a date (made up of a month object. for example. there are a number of different ways in which people express specialization. Specialization is either: • • the process of defining a new object based on a (typically) more narrow definition of an existing object. those who are familiar with an object-oriented programming language called Smalltalk refer to specializations as "subclasses" and to the corresponding generalizations of these specializations as "superclasses. The objects that comprise a composite object are referred to as component objects. It is common to say that everything that is true for a generalization is also true for its corresponding specialization. For example.Composite objects are objects that have an externally-discernible structure. Specialization and Inheritance Aggregation is not the only way in which two objects can be related. For example. a list of addresses is a homogeneous composite object. The rules for designing heterogeneous composite objects are different from the rules for designing homogeneous composite objects. One object can be a specialization of another object. or an object that is directly related to." Another way of saying this is that a checking ." Those with a background in the C++ programming language use the term "derived class" for specialization and "base class" for corresponding generalizations. It is useful to divide composite objects into two subcategories: heterogeneous composite objects and homogeneous composite objects: • • A heterogeneous composite object is a composite object that is conceptually composed of component objects that are not all conceptually the same. A homogeneous composite object is a composite object that is conceptually composed of component objects that are all conceptually the same. and more narrowly defined than. and the structure can be addressed via the public interface of the composite object. define "checking accounts" and "savings accounts" as specializations of "bank accounts. Depending on their technical background. Specialization is usually associated with classes. We can. It is usually only in the so-called "classless" object-oriented systems that we think of specialization for objects other than classes.
Many object-oriented systems. A telescope and a television set are both specializations of "device that enables one to see things far away." A television set is also a kind of "electronic device. and in turn. we often isolate useful. "automobile" is not a complete definition for any vehicle. and classes that represent these incomplete definitions are equally useful. a television set is a product of multiple inheritance. In object-oriented thinking. however. checking account. For example. we speak of specializations as "inheriting" characteristics from their corresponding generalizations. and a savings account is a kind of bank account. While we would never create instances of abstract classes. concepts such as these into their own special classes. People sometimes use the terms "partial type" and "abstract superclass" as synonyms for abstract class." Therefore. Abstract Classes We usually think of classes as being complete definitions. in everyday conversation." Operations . concepts. Some objectoriented systems permit only single inheritance. in other words. a situation in which a specialization may only acquire characteristics from a single generalization. but incomplete. make these characteristics available to their specializations via inheritance. Abstract classes are classes that embody coherent and cohesive. Still another way of expressing this idea is to say that everything that was true for the bank account is also true for the savings account and the checking account. a situation in which a specialization may acquire characteristics from two or more corresponding generalizations. and houses. and savings account was an example of single inheritance. In an object-oriented context. receives) characteristics from one or more other objects. allow for multiple inheritance." You might say that a television set acquires characteristics from two different generalizations.account is a kind of bank account. we most certainly would make their individual characteristics available to more specialized classes via inheritance. there are situations where incomplete definitions are useful. On the other hand. we might talk about such items as bank accounts. On one hand. However. Our previous discussion of the bank account. For example. but incomplete. consider the concept of an automobile. the "essence of automobile-ness. Inheritance can be defined as the process whereby one object acquires (gets. most people know what an automobile is. "device that enables one to see things far away" and "electronic device. insurance policies. It would be quite accurate to describe "automobile" as the set of characteristics that make a thing an automobile.
" "method interfaces. Passive selective iterators do not allow their users to change the object over which the iteration takes .: • • • A selector is an operation that tells us something about the state of an object. an iterator is an operation that allows its users to visit (access) each of the component objects that make up the homogeneous composite object. methods are not in the public interface for an object. we can say that a bank account "suffers" the operation of having a deposit made into it. i. and they are in the public interface of that object. an iterator would allow us to visit each address object within the list and then." or "methods"). Rather. change the state of the object.The public interface of an object typically contains three different categories of items: • • • operations (sometimes referred to as "method selectors. constants. "what is current temperature" would be an operation in the public interface of a temperature sensor object. So. Active iterators are objects in their own right." There are three broad categories of suffered operations.e. and we wish to print the entire list. For example. "deposit" would be an operation in the public interface of a bank account object. A constructor is an operation that has the ability to change the state of an object. The bank account can also "suffer" the operation of being queried as to its current balance. by definition. An operation in the public interface of an object advertises a functional capability of that object." Suffered operations are operations that meet two criteria: they are things that happen to an object. An operation that tells us the current balance of a bank account is an example of a selector operation. Passive iterators are further broken down into selective iterators and constructive iterators. For example. to print each address. Iterators can be further divided into two broad categories: active (open) iterators and passive (closed) iterators. For example. Some people also refer to suffered operations as "exported operations." "messages. an operation in the public interface to a mailbox object that added a message to the mailbox would be a constructor operation. and "increment" would be an operation in the public interface of a counter object. We refer to the operations in the public interface of an object as "suffered operations.) In the context of a homogeneous composite object. Passive iterators are implemented as operations in the interface of the object over which they allow iteration. but cannot. methods are hidden on the inside of an object. and exceptions. Unlike operations. The actual algorithm for accomplishing an operation is referred to as a method. in turn. while users of bank account objects would know that they could make a deposit into a bank account. for example. (Please note that some people restrict the definition of the term "constructor" to those operations that cause instances of a class to come into existence. they would be unaware of the details as to how that deposit actually got credited to the bank account. If we have a list of addresses.
how can we be sure that the ordered lists will know how to properly maintain order -." How could the generic list class tell if one fazooma was greater than or less than another fazooma? A solution would be for the generic ordered list to require a second parameter. Suppose that we wanted to create a "swap operation. class) that we desired to place in the list." There is a problem. The "<" that worked with fazoomas is an example of a required operation. could instantiate (make an instance) the generic ordered list with a "name class" resulting in the creation of an "ordered list of names class.no matter what we use to instantiate the generic ordered list? Suppose. Suppose. An ordered list is a list that must order its contents from the smallest to the largest. however. A composite operation is any operation that is composed. while at the same time swapping out an old item in the same list. we could argue that an operation that added an item to a list object. but which the object cannot supply itself.place. Some people refer to required operations as "imported operations. efficiently. We can also describe suffered operations as primitive or composite. It would not be unreasonable to implement this object as a parameterized class. Specifically.g. of two or more primitive operations. This second parameter would be a "<" (less than) operation that worked with the category of items to be placed in the list. Obviously." we mean a template that can be instantiated with the category (class) of items we wish to place in the ordered list. For example. or can be composed. In the case of our ordered list of fazoomas. that item would have to be placed in its proper position with respect to all the other items already in the list. a parameter over and above the category of items (class) that we desired to place in the list. or an operation that deleted an item from a list object were primitive operations with respect to the list object. This is not a primitive operation since we can accomplish this with a simple combination of the delete operation (deleting the old item) followed by the add operation (adding the new item). for example. Sometimes objects need help in maintaining their characteristics. Passive constructive iterators do allow users to change the object over which iteration takes place. By "generic. A primitive operation is an operation that cannot be accomplished simply. that we wanted an ordered list of "fazoomas.. this second parameter would be a "<" that works with fazoomas. that we wanted to create a "generic ordered list" object. every time we add an item to our ordered list. Given that we could instantiate the generic ordered list with just about any category of items. As an example. A required operation is an operation that an object needs to maintain its outwardly observable characteristics. one of the parameters would be the category of items (e." Constants . The swap operation is an example of a composite operation. and reliably without direct knowledge of the underlying (hidden) implementation of the object. for example." an operation that would swap in a new item in a list.
Error codes suffered from two major problems: • • No one was forced to actually check the value of returned error codes. This constant represents the maximum number of elements that can be placed in the bounded list." A bounded list is a list that has a fixed maximum number of elements. or part of an application. To understand how exceptions directly address both of these issues. and a set of information directly relating to the event that caused suspension of normal application execution. One of the pieces of information that would be returned to the requester would be an error code. in our example) are currently in the bounded list. but it can never contain more than the defined maximum number of elements. In some cases. and modifications) in the meanings of the special values assigned to error codes were not automatically passed on to interested parties. If any problems had occurred. Constants are objects of constant state. accomplish some work. Exceptions can be contrasted with an older. We can now determine how much room is available in the bounded list by inquiring how many addresses are already in the list. constants are provided more for convenience than necessity. In other cases. the error code would typically have a value of zero. You would request that an application. If all had gone well. the public interface of an object can also contain constants." The idea behind error codes was fairly simple.In addition to suffered operations. Changes (additions. A bounded list can be empty. Assume also that there is a suffered operation that will tell us how many elements (addresses. Assume that we place a constant in the public interface of our bounded list of addresses. less reliable technology: "error codes. Imagine that we want to create a "bounded list of addresses class. we first need to understand how exceptions typically work: • Exceptions may be defined by the environment or by the user. and then subtracting this from the previously-defined constant. Exceptions A third category of items that can be found in the public interface of objects is exceptions. such as in the case of encryption algorithms needing a "seed value. It was also quite common to associate different non-zero values of an error code with specific errors. . deletions. as with the bounded list example above. and it can contain fewer than the maximum number of elements." constants are an absolute requirement. the error code would have a non-zero value. Exceptions have two different definitions: • • an event that causes suspension of normal application execution. It can even contain the maximum number of elements. Tracking the effects of a changed error code value often consumed a significant amount of resources.
• When an exceptional (but not unforeseen) condition occurs. the better the overall system. Systems whose components are highly independent of each other are easier to fix and enhance than systems where there are strong interdependencies among some or all of the components. (People use different terms to express the activation of an exception. Unlike error codes. Executing a set of actions in response to an exception is known as "handling the exception. Exceptions cannot be ignored. Examples of exceptional conditions include trying to remove something from an empty container. changes in exceptions result in at least a partially automated propagation of change information. exceptions are placed in the public interfaces of objects. Once an exception has been activated. An exception will continue to be sent to higher levels of the application until it is either turned off or the application ceases to function. 1993. ." and attempting to cause a date to take on an invalid value like "February 31. If no locally defined exception handler is present or if the exception handler is not equipped to handle the exception. If the exception is one that the handler recognizes. the exception is propagated to the next higher level of the application.") This activation may be automatic (controlled by the environment) or may be expressly requested by the designer of the object or application. people use the terms "throw" or "activate." Less commonly. Highly independent system components are possible when there is minimal coupling among the components. directing an elevator on the top floor to "go up. normal application execution stops and control is transferred to a locally defined exception handler. An exception handler checks to see what type of exception has been activated. it demands attention. an appropriate exception is activated. In object-oriented systems. Changes in the public interfaces of objects very often require an automatic rechecking of all other objects that invoke operations in the changed objects." • • Once the exception is activated." Handling an exception deactivates the exception. Thus. The most common is "raise. a specific set of actions is taken. if one is present. Object Coupling and Object Cohesion Engineers have known for centuries that the less any one part of a system knows about any other part of that same system. and each component is highly cohesive. exceptions cannot be ignored. the exception will not be propagated any further.
This is necessary object coupling. To construct systems from objects. objects with low cohesion are more likely to be changed. on the other hand. The objects that make up an object-oriented system exhibit object coupling and object cohesion. if in the design of an individual object. You need some way of creating and dealing with large objects. and are more likely to have undesirable side effects when they are changed.Coupling is a measure of the strength of the connection between any two system components. nonnested objects. is a measure of how logically related the components of the external view of an object are to each other. if we are told that a date object is comprised of a month object. First. A system of objects is defined as two or more interacting or interrelated. Object cohesion. (We exclude simple aggregations of composite objects from our definition of systems of objects. a year object.) . we are unnecessarily coupling the objects. Systems of Objects In constructing object-oriented models and object-oriented applications. we give that object direct knowledge of other specific objects. Object coupling describes the degree of interrelationships among the objects that make up a system. Second. The more logically related the parts of a component are to each other the higher (better) the cohesion of that component. and the reliability of the systems that contain unnecessarily coupled objects. and lowers the cohesion of the date object. The more any one object knows about any other object in the system. and to the overall component. Unnecessary object coupling reduces both the reusability of individual objects. The more any one component knows about another component. For example. we must couple (to some degree) the objects that comprise the system. We want our objects to be as cohesive as possible for two reasons. objects with low cohesion are seldom easily reusable. Cohesion is a measure of how logically related the parts of an individual component are to each other. we should recognize that the color blue is not appropriate. a day object. and the color blue. the tighter (worse) the coupling is between those two components. one quickly finds that single classes and single instances are not enough. the tighter (worse) the coupling is between those two objects. However.
parameterized classes. on the other hand. there are very few physical connections that bind them together. . large. buttons. such as computer graphics windows or insurance policies. panels. kits are "granular. Such an application would not be viewed as a library. resemble applications. and/or systems of interacting objects) all of which support a single. metaclasses. completely disjoint public interfaces." While all the components of a kit are logically related. and the components of windows (buttons and check boxes) are themselves objects. and other objects into a working application that would control the elevators. For example. and in which there must be a direct or indirect physical connection between any two arbitrary objects within the collection. Systems of interacting objects. which are collections of items (classes. which are collections of items (classes. object-oriented concept. and/or other systems of interacting objects) all of which support a single. independently executing thread of control. coherent. other kits. It would be very useful if we had a library of windows and window components from which we could construct any window we desired. systems of interacting objects may exhibit multiple. non-class instances. A collection of windows and window components can be viewed as a kit. suppose that we wanted to construct an object-oriented application that controlled the elevators in a particular building.Systems of objects fall into two general categories: • • kits. lamps. Further. large. metaclasses. There may indeed be some physical connection among some of the members of a given kit. coherent. We would assemble elevators. Windows are objects. Graphical user interfaces normally contain several different types of windows. kits. for example. Lastly. Say. but as a highly cohesive whole. systems of interacting objects have at least one internal. object-oriented concept. that we had to create a computer application with a graphical user interface. nonclass instances. Kits resemble libraries. However. parameterized classes. The elevator controller application is a system of interacting objects. systems of interacting objects.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.