{"id":21,"date":"2004-07-22T17:18:18","date_gmt":"2004-07-22T07:18:18","guid":{"rendered":"http:\/\/www.thunderguy.com\/plusplus\/20050421\/21\/"},"modified":"2009-12-04T22:15:36","modified_gmt":"2009-12-04T09:15:36","slug":"dont-import-wildcards-from-non-standard-java-packages","status":"publish","type":"post","link":"https:\/\/thunderguy.com\/semicolon\/2004\/07\/22\/dont-import-wildcards-from-non-standard-java-packages\/","title":{"rendered":"Don&#8217;t import wildcards from non-standard Java packages"},"content":{"rendered":"<p>Import statements provide good documentation, but not if they contain wildcards. For example:<\/p>\n<pre class=\"code\">\r\n<code class=\"bad-code\">import com.zikzak.db.*;\r\nimport com.zikzak.util.*;\r\n\r\n   <em>...code...<\/em>\r\n\r\nWidgetId = new WidgetId();<\/code>\r\n<\/pre>\n<p>There&#8217;s no way to find out what package the <code>WidgetId<\/code> class belongs to without searching through the source tree. <!--more-->Much better to do this instead:<\/p>\n<pre class=\"code\">\r\n<code>import com.zikzak.db.Table;\r\nimport com.zikzak.util.WidgetId;\r\n\r\n   <em>...code...<\/em>\r\n\r\nWidgetId = new WidgetId();<\/code>\r\n<\/pre>\n<p>Now it&#8217;s clear what and where <code>WidgetId<\/code> is.<\/p>\n<p>This is not such a problem with well-known packages. For example, everybody knows what classes are in the <code>java.util<\/code> package, so this probably won&#8217;t cause any confusion:<\/p>\n<pre class=\"code\">\r\n<code>import java.util.*;<\/code>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Import statements provide good documentation, but not if they contain wildcards. For example: import com.zikzak.db.*; import com.zikzak.util.*; &#8230;code&#8230; WidgetId = new WidgetId(); There&#8217;s no way to find out what package the WidgetId class belongs to without searching through the source tree.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-general","tag-java"],"_links":{"self":[{"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":1,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":274,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/posts\/21\/revisions\/274"}],"wp:attachment":[{"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}