Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.