views:

72

answers:

5

In every web project most of the time the code is just being re-use. From the drop-down navigation, Rotating Header to CSS Grids. This process makes your workflow more faster and more efficient. I'm wondering how do people organized those scripts? Where do you store it? How do you break it down into category (javascript,css,php etc.)? so it can be easily find.

Because not every time you can access the internet and do a search on Google and searching it would take you some time to find it.

+1  A: 

Maybe it's just my style, but I don't do alot of copy&paste snippets across projects. If something is good enough to be reusable, then I take the time to create a proper function or class for it (including javadoc style documentation so eclipse can pick up on it). Then it's a simple matter to install it "site-wide" in your development environment. For php, add it in the include path and then tell your IDE to use it. For JavaScript, put something off the root folder of your local webserver ("/jslibs" or the like). If you use jQuery, you can easily turn your javascript snippets into proper plugins.

CSS however, is a complete clusterf*ck. I don't have any real suggestions for that.

Here are a couple more suggestions specifically for offline use:

  1. a local wiki to document things. If you're using subversion or git, I'd recommend trac as it integrates nicely.

  2. If you use firefox, get the Scrapbook plugin. It allows you to save web pages or snipptes of pages into a local searchable database.

MadCoder
+1  A: 

In my company, we build them into libraries. We have libraries called XD (experience design) for reusable UI components. Since we build with Maven, we use the standard directory layout to put Java. Flex, and JavaScript components in different trees, but they're all in the same project, and DEFINITELY in version control.

If you use this method (building libraries for each language) you don't have to cut and paste; just include the library. And any improvements made on one project can benefit all projects.

dj_segfault
A: 

I keep my copy-pasta code in Google Notebook. (Things like meta redirects and other stuff that's really specific and hard to remember.) Google Notebook is no longer open to new accounts, but there services / applications like OneNote.

The IDE I use supports templates, which are skeleton files you can load any time you create a new file (instead of creating a blank CSS or Javascript file, you can have all of your basic CSS rules or JS functions). I find templates very useful.

And finally, you can create your own libraries and deploy them as you would any other library or framework (jQuery, etc.). I have one or two of these on Google Code that I can easily pull with Mercurial and dump into a new project or server.

banzaimonkey
A: 

It is all smalltalk and organized, packaged, searched and refactored like all smalltalk code: in monticello packages that are versioned. The large javascript libraries have their own packages, the framework packages have dependencies on them and the customer packages depend on the framework packages.

Stephan Eggermont
A: 

It seems Snippets (Mac app) has been made just for this. A blog post answering your questions in detail (offline use, language categorization, etc) can be found here.

huitseeker