Previous | Table of Contents | Next |
We must consider one more key aspect of object-oriented design even though the SGML developer doesnt have to worry about it because, like so much else, a good DTD has already taken care of it. Object relationships must be carefully worked out in an object-oriented system, but the DTD has already done this for a document instance and its component objects. When dealing with object structure, object-oriented methodologies such as Boochs and Rumbaughs give you all kinds of object relationship options to consider, but one of these options covers just about everything that an SGML application developer needs to worry about: aggregation.
When you define the logical structure of a document in a DTD, you dont have to consider anything outside of the DTD. You have a document element, the pieces that comprise that document, and the pieces that make up those pieces. For example, the Bible is made up of testaments, which are divided into books, which are divided into chapters, which are divided into verses. A cookbook might be divided into chapters that are divided into recipes, which are divided into a title, optional illustration, optional attribution, introduction, ingredients, instructions, and suggestions for accompanying dishes.
In broader object-oriented development, aggregation is only one object relationship option, because some objects may be outside of other objects. If youre designing a bank simulation, with tellers, lines, and cash registers, none of these objects are parts of each other, and Booch, Rumbaugh, and others offer various categories in which to define the relationships between these objects. These options include the using relationship, in which an object of one class requires an object of another in order to perform some task (for example, a road crew worker cant dig a hole through the asphalt until a jackhammer is assigned for the task) and the association relationship, which identifies the relationship between objects of two classes, such as a cabdriver and that drivers assigned cab for the day. Other possible relationships, such as inheritance, instantiation, and metaclasses, have more bearing on object-oriented implementation issues than they do on the real world.
The aggregation category is all you need when dealing with SGML documents at the logical levelthat is, when planning out the relationship of your document elements. (The SGML equivalent of the physical level, on the other hand, is the entity structure, which is not yet an issue when youre at the application analysis stage.)
Rumbaugh cautions against overuse of aggregation and says when in doubt, use ordinary association. He includes several tests to consider if youre unsure whether aggregation is appropriate, and the relationship of an SGML document or element to its subelements passes all the tests:
We saw that the existence of a good DTD means that the majority of object-oriented system analysis and design has already been done and stored in a clearly defined notation that can be easily parsed and used to declare classes in an object-oriented system. The data structures have been defined the way an object-oriented developer needs them; all thats left for a proper object-oriented system is the specification of object behaviorin other words, what the document element objects will actually do.
An object-oriented SGML application can automate this process by:
In the section A Sample Smalltalk SGML System, later in this chapter, youll see a Smalltalk application that performs these two steps.
Youll then have a document object with component objects that fit nicely into a classic object-oriented system.
If good SGML design omits behavioral specification for document elements and object-oriented design requires it, what does a developer do about the behavior of these elements? Analysis of typical SGML systems reveals common services expected of many SGML elements; you can use this collection to define a core set of capabilities as a default starting point in an automated SGML-to-object-oriented application development system.
Previous | Table of Contents | Next |