Question

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?


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

Was it helpful?

Solution 8

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

OTHER TIPS

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

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

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.

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.

  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.

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

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 ./

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top