| ||
Modularization: A Concrete Example (continued) |
In the example which started on the previous section there were references to three fragments (by means of INCLUDE properties) that we have not yet shown. They provide a hierarchy of patterns for ordered entities. The basic ordered pattern is defined in the file ordered.gb, and it looks like this:
The slot OrderedMax appears where the implementation of the max method would be; this implementation has been taken out and placed in another file, in order to illustrate how the interface and the implementation of an entity can be separated from each other. The implementation fragment looks like this:
The ordered pattern is specialized in two directions, to text and to number which is itself specialized to int and to float:
All these patterns are made available in our program (in the file orderedUser.gb) by means of the INCLUDE properties, and the implementation in the file orderedImpl.gb was brought along because of the BODY property in ordered.gb. Note that no files include orderedImpl.gb, so the static analysis of the other files cannot depend on the contents of orderedImpl.gb; in other words, nobody depends on the implementation of the max method. With these patterns the system is almost complete. The only missing part is that the main program calls an asString method on an ordered object, and we have no such method available in the declarations so far. The next section explains how we can provide such a method unintrusively. |