Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I thought XML is better than Plist #5

Open
rpplusplus opened this issue Jan 18, 2017 · 1 comment
Open

I thought XML is better than Plist #5

rpplusplus opened this issue Jan 18, 2017 · 1 comment

Comments

@rpplusplus
Copy link

XML is easy to edit, and makes data simple.

@galenlin
Copy link
Member

galenlin commented Feb 5, 2017

Well, though XML can describe properties in attributes but it also has some limits. And without the editor it seems NOT THAT easy to edit. 😂

  1. XML limits the attribute name convention (should starts with letter or underscore then follows letters, digits, hyphens, underscores, and periods) which will breaks some custom initial-key features:

    • ! for events, like !click, !change
    • @ for tagged or alias views, like @title.text, @1.value.
  2. Plist is well supported by official:

    • Xcode Plist editor support
      • Copy/Paste line(properties)
      • [Drag] to move line(properties)
      • [Enter] to append a new line(properties)
      • [Tab] to next
    • Compress/Decompress support
      • With the plutil CLI, we can convert a plist to binary, xml format. futher more, the IDE can correctly display the Property List View from the binary and allow you to edit it directly.
  3. XML attribute value accepts string only which is hard to describe nested properties (dictionary or array).

    As example, we wanna to describe following properties:

    - properties (dict)
    	- backgroundColor = "#f0f0f0"
    	- clients (array)
    		- item0 (dict)
    			- clazz = "GithubClient"
    			- action = "/repos"
    

    in XML way:

    <PBTableView backgroundColor="#f0f0f0">
    	<clients>
    		<item clazz="GithubClient" action="/repos"/>
    	</clients>
    </PBTableView>

    As we see, the backgroundColor and clients are in the same level, but we had to create a new node("deeper level") for clients cause it's value is an array. This may also brings the naming convention discussions, should we use:

    • <item clazz="GithubClient" ...,
    • <client clazz="GithubClient" ... or directly
    • <GithubClient action="/repos" ...
  4. Plist performance is as well as XML. I just test the non-nested properties in BMParsingTests.m:

    • Plist, [0.001082, 0.001064, 0.000677, 0.000727, 0.000605, 0.000624, 0.000605, 0.000528, 0.000558, 0.000560]
    • XML, [0.001572, 0.001078, 0.000891, 0.000650, 0.000642, 0.000624, 0.000595, 0.000624, 0.000571, 0.000511]

    The nested data struct is hard to test cause we should implement a customized XMLParser for each XML.

Totally, we use Plist as the configuration file cause:

  1. Simple to edit
  2. Easy to view
  3. Less convention
  4. More customizable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants