Information dummy question about code and the good practice
#1
Just to be sure about code and the good/best practice.

sometime the code can be like this (eg : Skin Estuary) :

syntax 1 :

xml:
<include content="My_Include">
    <param name="Name_A" value="Value_A" />
    <param name="Name_B" value="Value_B" />
</include>

syntax 2 :

xml:
<include content="My_Include">
    <param name="Name_A">Value_A</param>
    <param name="Name_B">Value_B</param>
</include>

syntax 3 (syntax 1 mixed with syntax 2) :

xml:
<include content="My_Include">
    <param name="Name_A" value="Value_A" />
    <param name="Name_B">Value_B</param>
</include>

Of course I have make some test in my side. All seems to be the same for me.
​​​​​​is there only a reading confort for each coder or there is something to know about a practice vs an other practice ?

Thanks for any answers.
Reply
#2
They are, as you have seen, all the same.  For what you've shown, that's just a coding preference.  I would suggest picking one and sticking with it though, or at some point you'll end up with a dangling item that will mess everything up.  And if you're modding an existing skin, I'd follow whatever convention the original skinner used.
Reply
#3
(2024-11-15, 23:25)pkscout Wrote: They are, as you have seen, all the same.  For what you've shown, that's just a coding preference.  I would suggest picking one and sticking with it though, or at some point you'll end up with a dangling item that will mess everything up.  And if you're modding an existing skin, I'd follow whatever convention the original skinner used.

Thanks a lot for your explaination very clear.

EDIT :
I never has the opportunity to say thank you too for your perfect addon "script.audio.profiles".
Reply
#4
There is one very minor difference not covered here.

When defining *defaults* for an include you use the "default" attribute instead of the "value" attribute in the param tag.

xml:

<include name="My_Include">
<param name="Name_A" default="Value_A" />
<param name="Name_B">Value_B</param>
<definition>
</definition>
</include>

<include content="My_Include">
<param name="Name_A" value="Value_A" />
<param name="Name_B">Value_B</param>
</include>

Notice that the attribute (A) approach is not interchangeable for defining defaults and values because the param "type" is made explicit by the attribute.
Whereas in the element (B) approach, the same line of code can be used for defining both defaults and values because the param "type" is implicit in the element.

A is more "proper" and is especially useful if you ever need to do a find/replace; whereas B is more convenient for copy/pasting and writing code quickly.
Arctic Fuse 2 - Alpha now available. Support me on Ko-fi.
Reply
#5
(2024-11-16, 05:58)jurialmunkey Wrote: Notice that the attribute (A) approach is not interchangeable for defining defaults and values because the param "type" is made explicit by the attribute.
Whereas in the element (B) approach, the same line of code can be used for defining both defaults and values because the param "type" is implicit in the element.

A is more "proper" and is especially useful if you ever need to do a find/replace; whereas B is more convenient for copy/pasting and writing code quickly.

Very interesting information.
I never thinking about that.
Thanks a lot for sharing your "huge" experience.
Reply

Logout Mark Read Team Forum Stats Members Help
dummy question about code and the good practice0