Avoid using functions before their declaration
Pattern example (here, in Javascript):
var foo = myFunction(10);
// eventually some stuff…
function myFunction(param) {
  // your function definition
}
Why you should care
Have you ever tried to watch a movie by starting in the middle of the story? It is hard to really understand who’s who since you may have missed some important details that were explained in the first scenes. Most (approx. 99.9%) developers read their source code by scrolling down, hence function definitions should be placed before (above) they’re used in the application, in order to know the different parameters of a function they’re about to modify.
References:
http://eslint.org/docs/rules/no-use-before-define
http://javascript.crockford.com/code.html
CAST recommendations
For readability purpose, it is better to define a function before using it, as follows:
function myFunction(param) {
  // your function definition
}
// eventually some stuff…
var foo = myFunction(10);
About CAST and Highlight’s Code Insights
Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.