Template talk:Popdens

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Apparent problems[edit]

{{Data/preload}} says that {{Popdens}} is for use on the page List of sovereign states and dependent territories by population density ("for use with" would be better than "for use on", I think). However, the output produced by this template does not appear to be the same as the wikitext needed for table rows there. I have sandboxed a version which does seem to work at {{Popdens/sandbox}}. I tested it with {{Data Philippines}} (currently on row 12 of one table there and on row 40 of another) as follows:

|{{Data Philippines|Popdensity/sandbox}}

Should the sandboxed version (or possibly an optimized version thereof) be moved into the template? Is there some reason it should not be? Have I misunderstood something here? Wtmitchell (talk) (earlier Boracay Bill) 12:07, 25 January 2014 (UTC)

"used with" is symmetric and therefore less specific: "A is used with B" is the same as "B is used with A" or "A and B are used together". However, "a call of template A in the wikitext of page B" is not the same as "a call of template B in the wikitext of page A".
Since {{Popdens}} is not used elsewhere it is fine to update it to the currently required format on the page List of sovereign states and dependent territories by population density, so that it can be used there again. - Patrick (talk) 01:05, 27 January 2014 (UTC)
Looks good at first glance. Unfortunately that doesn't say much: These templates are a horror to read. You should test this thoroughly by test-editing List of sovereign states and dependent territories by population density (and not saving the test-edit): Use your template, and then try all sorts of border cases and example cases. That's what should be done for all programming. For numbers: Try zero, small number, big number, negative number, real number, negative real number, leading zero, empty input, separators, letter instead of number and so on. Correct input should give correct output. Other input should fail gracefully (Generally. Not so easy here. Hopefully loops are caught by the interpreter ^_^. If you can manage to output e.g. an empty string for faulty input, you are good.). Don't hesitate to deploy your solution if it is better than the current one. Tomdo08 (talk) 20:17, 15 February 2014 (UTC)
Thanks for the response, and of course you are right. My original rewrite was a horror, and I've redone it with much simplification. One thing I found in the simplification was that {{convert}} was silently making a judgment that the output precision should resemble the input precision (and converting 300,000 km2 to 120,000 sqmi instead of 115,831 -- see Template talk:Convert#km2 to sqmi). The template is now live, and it should have had more testing before going live. I ought to revisit this and do more testing along the lines you suggest -- I'll try to get around to doing that. Wtmitchell (talk) (earlier Boracay Bill) 23:20, 15 February 2014 (UTC)
I did not mean especially your template to be a horror. All templates are a horror to read (^_^) Tomdo08 (talk) 11:43, 29 May 2014 (UTC)