To implement the patch generator in Abiathar, I need to store some configuration. Unfortunately, the XML config file has begun to be a giant pain to work with. Not only is it unnecessarily bulky, it is difficult to update (to add fields into) and some areas - especially the inspector settings - are complicated and difficult for users to modify.
Therefore, I invented a new way to store configuration information. It's kind of like JSON, and way more strongly-typed than what I have. Currently, I have to pass the ConfigHelper a "path" to the configuration entry whenever I want to access a variable. There's caches for frequently-accessed config entries, like the hex/decimal defaults. All of this is really a mess and I want to be able to use something like "Config.Colors.Grid" (an actual object) without having giant methods that need to be changed all the time to save/load the config.
My way is Fleex Reflective Object Field Configuration, FrofConf. It identifies configuration entries in a config object with attributes and reflects over them to write a hierarchy. Currently, it supports numbers (of all kinds, loaded using field type), strings, compounds, and lists (of any type, including compounds and other lists). All structure and type data is determined by the object. Addition of new fields is simple: add the configuration field to the object, the default (from the constructor) will be used when loaded for the first time, and all fields will be saved.
Today, I got everything about this system working. Tomorrow, I will actually have Abiathar use it. This will involve a major rip-out of the XML stuff, but it will definitely be worth it for code cleanliness and maintainability.
No comments:
Post a Comment