XmlObject - Adaptive Object Model

Better Designs Faster

Tic-Tac-Toe Example

The Tic-Tac-Toe game is another very simple application that exists only for demonstration purposes.  To start the game enter the following command at the CLI prompt.

                 load TicTacToe

There are only two commands start and choose.  The start command starts a new game and the choose command allows the current player to choose which cell to occupy.  The game will automatically keep track of whose turn it is and signify the winner.

.If you have defined the virtual drive as described on the download page, you can look at the application metadata by clicking here.  Otherwise navigate to the TicTacToe.xml file and open it in an editor.

The Tic-Tac-Toe game is different from the WavePlayer and more like production development.  The game has state that must be managed.  Here is the class diagram layout.

Tic-Tac-Toe Diagram

When looking at the metadata, one item to note is that the game, row and column elements belong to a different namespace and use a different prefix than the other elements.   If you look at the AssemblyInfo.cs file you will notice that the AssemblyDescriptorAttribute defines the TicTacToe DLL as able to create Type objects for this prefix and namespace.  Step through the GetAssembly code in the Resolver class to get a feel for how the GameElement, RowElement, and ColumnElement objects are instantiated.  Now we are truly working adaptively.  As the parser is parsing the XML it uses the information there to determine what objects to instantiate.  This example does not show it but this works just as well when the XML is assembled at runtime vs. being loaded from disk file. 

I use this same design in my regular day to day work with much larger object models.  There the challenge becomes managing the many different Assemblies that define Types.  I use simple naming conventions and the file system to keep everything straight.    The XML namespaces are perfect for this sort of thing.  I put the additional business logic in the GetAssembly override. 

I am just waiting for the day when I am challenged  to process streaming data. 

XmlObject Graphic