Jump to content

What do you think is the best way to organize your code?


Aro

Recommended Posts

Outside of using a framework I follow some simple rules.

 

/_includes

This holds all scripts that should not be accessed directly from your browser, ie your library code base, header files, footers, search scripts, helpers, etc...

 

/javascript

/css

 

No other directory exists unless it's an actual page.

 

In my includes i have things like:

/_includes/elements -> inline elements, like a photo gallery

/_includes/helpers -> procedural and OO files, typically procedural will be in one file OO is one class per file.

/_includes/models -> data access classes

/_includes/controllers -> scripts to process form actions

/_includes/forms -> html forms

/_includes/third-party -> code base brought in for specific tasks.

 

 

There's no right or wrong answer, just be consistent across your projects and find what works best for you.

 

  • 4 weeks later...

That's correct, there is no right way.  However, the most common organizational structure I've seen is to have:

 

  • javascript
  • css
  • includes

 

I use JavaScript libraries that I download online, jQuery, Spry, etc.  I like to have a folder for each version.  I do this so I can keep each version separate from each other in case I need to upgrade.

  • /javascript/spry/spry_version1/
  • /javascript/spry/spry_version2/

 

If I update my own files, I won't create new folders for versions.  I'll just let Subversion take care of versioning at that point.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.