views:

335

answers:

10

I've got several modules containing functions, classes and templates that I keep in a directory called (hah!) 'reuse'. I know the content reasonably well, so to find a particular class or bit of code doesn't take too long, but it is slowly growing in size and I need some sensible method to store them for easy search & retrieval.

How should I do this?

+3  A: 
  • Group the sources by area of use (network, security, text processing, etc); best in directories for easier browsing.
  • Tag functions by adding keywords into the source documentation. Use an appropriate comment markup system (like javadoc) and create some kind of indexable docs.
  • Search by using some kind of full text search (grep -r, google desktop) on your sources.
David Schmitt
I already use a form of grouping with prefixes to the filenames, and more or less search them as you suggest. I do not index them (yet), but the markup idea sounds plausible: a kind of hyper-linked doc that allows me to open/browse the modules?
slashmais
That really depends on the language you're writing in. There is Sandcastle for C# to create CHM files, javadoc for java creates a bunch of HTML. Most languages have such doc systems.
David Schmitt
A: 

You can divise all you classes in directories.

What language is for the question? Because .Net you could have a librairy like a DLL divised with namespace.

Daok
A: 
  1. Group the functions/classes/templates into modules/directories by function. Pretend you'll be releasing them as open-source libraries; consider how you would want someone else's code to be organized. Eventually, it will be someone else's code: you, a year or two ago.
  2. Use a documentation system. Doxygen will generate a handy HTML code browser for you.
skymt
+1  A: 

Hi!

Usually, I group my files depending on the general purpose of the files.

Ex: Reuse\Database Reuse\Graphics Reuse\Math Reuse\Etc...

You can then sub-group your groups

Reuse\Graphics\2D Reuse\Graphics\3D

HTH

vIceBerg
A: 

Post it on Stack Overflow! :)

Sklivvz
+1  A: 

Depends on the system, but the moment the amount of reusable could reaches a certain threshold I tend to try to convert logical chunks of it into "real" libraries in the same sense like you would use from 3rd parties (with documentation etc.) and put them into the respective library path, so that they become truly reusable.

If you don't mind giving them away under some OSS license, you could even go as far as putting them into the CPAN/PyPI/PEAR-equivalent of whatever environment you're working with. This adds even more reuseability.

I guess the important part still is that you bundle your code into real libraries. Then the retrieval part should be much easier since mostly automatic.

Horst Gutmann
slashmais
A: 

Had a debate on this a while ago. Standard folderization of your code is good for readability and organization, but when you want to just grab things, the one other way is to use tagging somehow (like by adding tags to the file names or other meta data). Tags work good in the place of folders because you can dig up specific or general things quickly, whereas with folders you need to dig through trees to get specific stuff.

Tags: O(n). Folders: O(n^2)

Maybe. :P

Daddy Warbox
A: 

A related question can be found here: full text search for source code

slashmais
A: 

Folderization according to language (subdivided into function), with tags, in a VCS'd directory, with Doxygen/Perldoc/*Pod/*-extracted documentation. You'll have an easily greppable archive of reusable modules/documentation instantly portable into your working ./

pookleblinky
A: 

This question covers much the same ground & I'll close this question in it's favor.

slashmais