Nowdays, XML is very popular. It seems that every data-driven approach, should be done using that magical format. And indeed, most of the times, it's a good idea, XML has parsers for any programming language (SAX can be a nightmare, but it's nice) and has some really nice tools for transforming data.
But be aware of what your data is. Most of the time, data-driven is not about pure data, but transformation of some data or binding of objects with other objects. This kind of information, is difficult to encode in XML, and most of the times you end up writing something that starts to look like a scripting thing.
Hints of XML abuse:
But be aware of what your data is. Most of the time, data-driven is not about pure data, but transformation of some data or binding of objects with other objects. This kind of information, is difficult to encode in XML, and most of the times you end up writing something that starts to look like a scripting thing.
Hints of XML abuse:
- Macros in XML strings. I.E. attribute="{database_object{index}.type}" or filename="{getpath:{system.currentpath}}{getfile:{system.projectname}}"
- Logic in XML tags. I.E. "if" tags, "variable"-definition tags, "call" tags, that evaluate other nodes with the current state of the parser...
Ask yourself, why am I using XML? Why am I parsing things, pulling them from data? Wouldn't be better to use a scripting language to push data into the runtime instead? Remember that scripting languages most of the times are more than suited for expressing data initialization, and they provide you the power of expressing transformations and logic, when you need them. Maya scene files, are a MEL script that spawns all the objects in the scene. Also scripting languages tend to be efficient, and usually come with a nice and fast binary compiler...
No comments:
Post a Comment