Skip to content

What is the DOM For

Gary edited this page Aug 27, 2014 · 1 revision

Table of Contents

The DOM offers a comprehensive way to handle application data, containing interdependent parts to handle data definition, adaptation, editing, event monitoring, and persistence.

Application data is the data created and saved by your application in some sort of document, which you can open later with the application to edit and add more data.

You can use ATF without its DOM. However, the DOM encompasses so many compelling features for handling application data that you will probably want to use it for all your ATF applications. We think you'll find the DOM really is lovable once you get to know it.

The DOM consists of several parts and is flexible. Just because you use one part doesn't mean you have to use other parts. There are advantages to using the entire package though, which are revealed as you explore DOM features.

ATF DOM Overview

When you examine your application's data, you see that it falls into various types and collections of those types. Data types can have attributes associated with them. There is usually some sort of hierarchy to the data, some data elements containing other elements. All together, this is your data model. With ATF's DOM, you can define your data model either programmatically in C# or in an XML Schema file.

The hierarchy of data types lends itself to representing application data as a tree of nodes. ATF defines a {''}DomNode{''} class to represent these nodes. Each DomNode is considered to be one of the types you defined. Each piece of data in your application can be associated with a DomNode. Once this connection is made, your application can handle its data by manipulating DomNodes. All the application data is in a tree of DomNodes, and the tree reflects how data is contained in other data.

When accessing your data in the DOM, it may be more convenient to use a "business class" as the view of your data, rather than using the DomNode directly. We call this adaptation. Doing so decouples the data representation from its usage throughout the rest of your application and provides type safety and improved code readability and convenience. The ATF DOM allows you to adapt each DomNode to other types of C# objects. A particularly useful DOM adapter is ATF's {''}DomNodeAdapter{''}. Classes deriving from DomNodeAdapter have convenient methods and properties for accessing the underlying DomNode. You design the DOM adapter class with an API that's convenient for doing whatever you want with that kind of application data. For example, you can easily define C# properties in the DOM adapter class that correspond to the underlying data type's attributes. Setting the property results in changing the data's attributes. For more information on how adaptation works in general, see Adaptation in ATF.

You can also define events on the DOM adapter that correspond to changes in the data. When an event occurs, the application can take the appropriate actions for the data change. For instance, you can validate data as it's entered.

With the DOM it's easy to display DOM data in a property editor control so you can edit properties, that is, attributes of your data objects. For each attribute you want to edit, define a property descriptor, which is an object containing attribute information. For more information, see DOM Property Descriptors.

It's essential to save application data to continue creating and editing it later. ATF provides a DomXmlWriter class to save the entire DomNode tree to XML, using the information in the type definition file. You can read the XML file back to a DomNode tree using the DomXmlReader class so the user can resume editing.

Topics in this section

Clone this wiki locally