× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Use good names

Joe Sak
Sep 22, 2014
<p>Declare your variables and functions with readable, clear names. Forget abbreviations. They may save you time in typing now, but they'll add time to other developers and yourself in the future when it comes time to decipher what the hell it means. The name of your function or variable should exactly match its intent. Use nicely named private variables and functions in place of confusing code.</p><p>For a trivial example, </p><pre><code class="language-ruby">if response.env['statusCode'] == 200 # do something great else # oh no end</code></pre><p>could be</p><pre><code class="language-ruby">if response_was_successful? # do something great else # oh no end private def response_was_successful? response.env['statusCode'] == 200 end</code></pre><p> </p>
comments powered by Disqus