Part II: Other Benefits Gained from the Code Document Object Model
The Code Document Object Model presents us with other benefits, except for the ones describe in part I of this article:
- Working with .NET is not limited to a single language and one could code in languages such as C#, VB.NET, Managed C++, JScript.NET, J#, NetCOBOL, Eiffel# and other languages that implement the CLI. Using the Code DOM gives a single representation for all of these languages.
For instance, using the Code DOM, I could save my object graph to both a C# document and a VB.NET document, by altering only a few lines of code.
- The logical structure of a code document is not a flat one, even though its physical structure is flat. A code document contains namespaces, classes, methods, loops, etc.
All of these code structures are contained inside one another, creating a hierarchical structure. This is the way Code DOM represents the document.
For instance, should we take a document describing one class with one method, the object representing the method would be contained in the object representing the type, which in turn would be contained in the object representing the namespace, and so on.
Please note: The Code DOM is not a compiler. It simply represents code in an object graph. In order to check for the code's correctness, it must be sent to a compiler.