|
Glossary: Object Model
|
|
A scriptable application can define classes, roughly comparable to the “things” that constitute its world. (For example, iTunes defines a playlist class and a track class, and the Finder defines a folder class and a file class.) Classes can have properties and elements, whose value type can be a class. Thus, in theory, for a given application, there is a hierarchical relationship of ownership—of containment—amongst its classes. (For example, in iTunes, a playlist “has” tracks, and in the Finder, a folder “has” files.)
In theory, this relationship can be expressed as a “tree”, a hierarchical structure starting with the application itself, and containing every object in the application. Indeed, this tree is vital to your use of AppleScript to communicate with a scriptable application, because it is why you are able to refer to an object in the first place. (For example, you can speak to the Finder of file 1 of folder "Mannie" because the Finder “has” folders and a folder “has” files.) This tree of the objects that you can refer to is the application’s object model.
Script Debugger exposes an application’s object model in two places:
In a Dictionary window, the diagram drawer shows you the application’s containment hierarchy as a tree.
In a Dictionary window and in other places, an application’s actual objects are displayed hierarchically through an explorer view.
I say “in theory” because in reality things are not so simple. The containment hierarchy is describing what’s possible, not what’s real, and therefore infinite recursions and circularities can result when you try to express it as a simple tree. For example, in the Finder, in real life there could never be an infinite depth of folder containment. In the containment hierarchy diagram, however, you can keep opening “folder” entries to get “folder” entries inside them, and so on, forever and ever (or until you get bored), just because as a theoretical matter, it’s always true that a folder can contain a folder. If this confuses you, and you’d rather see the object model as it exists in reality, use the explorer.