{"id":4901,"date":"2014-03-30T16:39:25","date_gmt":"2014-03-30T16:39:25","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/why-declare-a-function-argument-to-be-final-collection-of-common-programming-errors\/"},"modified":"2014-03-30T16:39:25","modified_gmt":"2014-03-30T16:39:25","slug":"why-declare-a-function-argument-to-be-final-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/why-declare-a-function-argument-to-be-final-collection-of-common-programming-errors\/","title":{"rendered":"Why declare a function argument to be final?-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m currently working my way through the book &#8220;Teach Yourself Android Application Development in 24 Hours&#8221; published by Sams. I&#8217;m relatively new to Java, Android or otherwise. I have a very solid background in ActionScript 3, which has enough similarities with Java that the language itself isn&#8217;t hard to grasp, but I do still have some questions about the rationale behind some of the code samples in the book. For example, here&#8217;s a function that comes with the sample code for Hour 9:<\/p>\n<pre><code>private void processScores(final TableLayout scoreTable, \n      XmlResourceParser scores) throws IOException, XmlPullParserException{\n<\/code><\/pre>\n<p>In this function signature, the authors have declared the scoreTable argument as final. I&#8217;m a little puzzled as to why they did this. It wouldn&#8217;t cross my mind to even attempt to assign a new value to the function argument scoreTable (it&#8217;s considered a bad practice in ActionScript). Further, I haven&#8217;t actually seen anyone do this in any of the real-world Java I&#8217;ve examined or ported into AS3.<\/p>\n<p>Is there something specific about Android development that makes it a necessity to sometimes declare certain function arguments as final?<\/p>\n<p>Why is the TableLayout object declared final, but not the XmlResourceParser?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m currently working my way through the book &#8220;Teach Yourself Android Application Development in 24 Hours&#8221; published by Sams. I&#8217;m relatively new to Java, Android or otherwise. I have a very solid background in ActionScript 3, which has enough similarities with Java that the language itself isn&#8217;t hard to grasp, but I do still have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4901","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4901"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4901\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}