DarkMultiPlayer Client

DarkMultiPlayer Client

38.8k Downloads

XML instead of configuration .txt files

Rene-Sackers opened this issue ยท 9 comments

commented

I was thinking, wouldn't it be a lot cleaner to implement XML files for stuff like configuration, mod parts list, and so forth?

I'd be happy to do this, but I was just wondering, if I do, would such a change be accepted on a pull request?

commented

I don't think it is a good idea after all. Why change a plain text file to XML? Plain text file is human readable...

About it being accepted: I don't think so, depends on darklight. For me, config files key=value are the best option we have. XML is a mess.

commented

I would claim the exact opposite. XML is structured and easy to read, and I believe it's a lot faster to parse using XML serializers/deserializers instead of what is currently used.

And as far as I know, most people who know how to port forward to set up a server, also know how to open a .xml file. Parts like 0.0.0.06702 should be self-explanatory. But idk. I guess that's up for discussion.

It's just a minor enhancement, really. 0 priority.

commented

XML:
https://github.com/godarklight/DarkMultiPlayer/blob/master/Client/Settings.cs#L70-L271

Plain text files:
https://github.com/godarklight/DarkMultiPlayer/blob/master/Server/Settings.cs#L36-L126

Code wise adding a setting to the plain text file is much easier as they are automatically picked up, but that's just a code thing too.

Err, I'm indifferent either way - personally I think I'm using XML wrong in the client and we should restructure it a little, but I'll leave this issue here as a reminder that I feel like something has gone wrong in the client's settings code.

I also dislike my use of ints instead of the enum string in the server settings file (eg: modcontrol,4 compared to modcontrol,SUBSPACE) and using the comma instead of an equals sign (what was I thinking??), but these are pretty small issues ;).

For anyone who wants to suggest using JSON, no - it's a horrible format and it's object is even worse to use than XML :)

commented

Code wise adding a setting to the plain text file is much easier as they are automatically picked up, but that's just a code thing too.

Well, with XML, we'd use serializers. It's literally as simple as adding a property to a class.
The way you do it in

https://github.com/godarklight/DarkMultiPlayer/blob/master/Client/Settings.cs#L70-L271

is pretty... Uhh... Yeah, ok. Let's just say... XmlSerializer :D Idk if you've ever worked with that, it'd literally be
new XmlSerializer(typeof(MyClass)).Deserialize(myStream), and a class would come out with all properties filled.

Here's a good example. Look at "PurchaseOrder". http://msdn.microsoft.com/en-us/library/58a18dwa(v=vs.110).aspx

commented

Serialisers generally only work when the object isn't subject to change - this is one such object that does :-/

The good news is that it's available in .NET 3.5 which is what we are targetting for DMPClient - I'll consider it, but something needs to change around this area, I'm just not sure if I like XML or not :P

commented

erm, JSON is used almost everywhere. It's like 75% JSON and 25% XML.

commented

erm, JSON is used almost everywhere. It's like 75% JSON and 25% XML.

Haven't seen evidence to support that, but either way, it's still the worst idea to use that as the settings file imo.

commented

I'm going to close this issue for now. I might make a pull request later with an XML format implemented. At that point, discussion can be picked up again on whether or not to accept it ;)

commented

XML is just obsessively redundant. Every time I see an XML properties file, I cringe at the sheer waste of space.

If you're going to use XML, please make a schema.