Wildcard Imports & Static Imports

I don’t think wildcard imports should be used in the documentation (bad example) because it does not show where certain classes, methods (static) or variables (static) come from and it encourages people to use them.

Additionally, should static imports be encouraged too?

I found an instance of a static wildcard import on the TextTemplates page.

1 Like

You could open an issue at SpongeDocs. I think the decision for this code style was to shorten the code lines in length. But I also agree that it is difficult or sometimes impossible to know where a method comes from without looking at the java docs or trying in the IDE.

I would ordinarily agree with you, but for that particular example I think it would be best to leave the static imports so the code sample is more readable. Had the TextTemplate. been included where it was replaced, I think the whole example would have been harder to decipher. Others on the Docs team may have differing opinions.

Actually, on that topic, there is a voluminous PR in progress by @12AwsomeMan34 that sets a lot of nice linkages to the Sponge Javadocs. That should help somewhat, and an issue wouldn’t be out of place, but feel free to discuss things with the editorial staff on #spongedocs IRC too.

3 Likes