On Tue, Jun 15, 2010 at 12:25 PM, Eric MSP Veith
<eveith / wwweb-library.net> wrote:

> so there's no actual best practice regaring require() placement?

The best practice is to put it where it makes sense to put it, bearing
in mind you might have to read your code again in two years, or
someone else might have to read your code.

The convention is to put requires at the top of the file because it's
immediately obvious what other libraries the code within the file
depends on.

But, obviously, you are trying to structure your code and your files
in a way that breaks that convention.  So, either write your code
differently, structure your files differently, or move your requires.

If you move your requires, I'd put them outside of the class bodies
and method bodies, but as close to the relevant code as is reasonable.

You might also consider a comment or note someplace explaining why you
are doing things differently.


Kirk Haines
Developer
Engine Yard