Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: How do you organize your code on your machine?
41 points by wfarr on Dec 27, 2009 | hide | past | favorite | 51 comments
Currently I have a Code directory which is littered with all sorts of stuff and in general is pretty unorganized. Between small code snippets and fully-fledged projects, the whole directory is a complete mess.

So, how do you organize your code?




  ~/code
  ~/code/${company_or_topical}
  ~/code/${company_or_topical}/${project}
Where company or topical are things like 'cloudkick', 'asf' or 'personal'. (I guess you could say, its "who owns the IP").

Some of these subdirectories are actually symlinks to encrypted DMGs, again depending on who owns the IP.

Project is the top level checkout of the projects.. My 'asf' (aka Apache Software Foundation) directory contains 84 project level checkouts.

I also keep a ~/work/temp directory full of random source tarballs if I need to look at how something works. Currently contains glibc, python 2.6 & 3.1, dojo, and about 30 other open source projects, normally ones I'm not normally involved in patching, but often run into... difficulties with. Nothing resolves bad documentation quicker than looking at the source code...

I tend to nuke temp once every 6 months.


I do a similar procedure, but I prefix the company or topic with an @ symbol to signify the underlying directory is a group.

IE:

~/code/@asf/httpd-dev ~/code/@asf/hadoop-trunk ~/code/@linux/linux ~/code/@linux/git

The @ symbol will sort the grouped directories first when sorted by alphabetical.


"""Some of these sub-directories are actually symlinks to encrypted DMGs, again depending on who owns the IP."""

That is how I handle customer proprietary data also for customers who want their work encrypted.


I use Knox - http://www.knoxformac.com/ - similar thing, much nicer UI.


Almost the same. But i have one more level above ${company_or_topical}, ${language}. I don't really know why, kind of a personal tradition.


Plus a /open_source/ folder for sources of OSS projects i follow or hack on.


Wow, I also have ~/code directory, with each subdir as a local copy of a different project repository. Logical, I guess. :)


Ha, that's precisely how I organize it too :)


Everything I'm currently working on:

  ~/Projects
Older stuff, or projects on hold:

  ~/Projects/ARCHIVE


Haha... No Way! Only difference is mine it's the same without capitalization.


I leave ARCHIVE in all caps because most of my project names are all lowercase, and that keep it from popping up in auto-tab completion. Color me lazy. :)


I do almost the same thing: ~/projects and ~/projects/old

I also have ~/tmp, which is where I put things I'm unlikely to need more than once or twice. Keeps my desktop clear and my projects folder uncluttered.


I use ~/proj/${SOME_PROJECT}/

Tarballs go in ~/proj/v/


Each project gets its own folder that contains branches, helper scripts, release files, notes, etc. Nothing related to the project goes outside that folder... except:

Working copies, demo code, samples, etc of dependencies of my projects are kept separate to avoid polluting my backups with stuff that isn't mine.

When learning a new language or framework, I consider it the same as a project and make a corresponding folder. Good to keep learning material, notes, project Euler snippets, etc.

Random snippets, quines that print sierpinski's gasket, and other useless stuff goes into the "Snippets" folder.


Two folders,

Sandbox: Contains code i'm working on or projects that i still consider active. Some of them i've converted to github.

Archived: Contains old projects or code, that are inactive, or somethings that are not on my plate in the near future.

For code snippets you might use gist on github, but i tend to use onenote. I have a queries notebook open on MS Onenote, and anytime i google search some new snippet, troubleshoot advice, configuration detail etc, it goes that notebook, with keyword tags.


Weird, I thought this would be more common, I use:

~/Dropbox/code/<language>/<project name>/

it's all backedup and available immediately on all my machines, pretty handy. sometimes I use git inside of dropbox, but I'm still learning git in a real way so not all of my code is in it.

This is a fun thread to read, I'm starting to question my methods. At the very least seems like there is no reason not to have everything I write inside of git (or some version control).


there was an essay/article going round a few years ago describing how stallman had an entire account on cvs and would simply check it out wherever he was...



thanks, that was probably it (i looked myself but couldn't find anything, probably because of the wrong person).


One thing I can tell you: I'll NEVER be satisfied with how my code is organised on a hierarchical filesystem (and don't tell me I can simulate a graph properly with symlinks).

I think some sort of tagging filesystem would be appropriate.

Also, I hate how most programming tools assume I want to choose a "canonical" representation of code into files. I'd want to mostly don't care how the code is organized on disk and then write queries which let me view and edit code coming from multiple different files at once.

As a completely hypothetical, contrived example, let's say I was still doing Java and had a big class with many getters and setters, I don't want to choose whether I want the getter and setter of each attribute organised in pairs or whether I want all the getters first and then the setters. I want to be able to write a query that will constitute a new view, so if I want either option I just have to switch views. A third view would simply be the physical representation on disk, which is still needed from and dependencies-loading standpoint. This way of working would truly shine in much more complex scenarios but I hope you see what I mean.


Two folders, 'sandbox' and 'projects'.

'sandbox' is organised by language, with code snippets and small projects in each folder. If anything becomes of the small projects they migrate to the 'projects' folder. Anything in the projects folder means it must be in a repository, git or svn.


~/gh/ is where I throw all my GitHub clones.

~/svn/ is where I throw my SVN checkouts (sometimes google code stuff, but mainly just python trunk until it gets fully hg'd)

~/scratch/ is where I create subdirectories for my quick-and-dirty scripts, or if I need to `cat` something somewhere real quickly.


Mine is somewhat similar:

~/sandbox/${vcs}-sandbox/${project}/

I'm thinking about removing the ${vcs} level though since I've got over 50 projects in 5 different VCS directories and it's getting hard to remember which vcs each one is in.


My good code I push to github. Everything else I occasionally delete or archive to my dropbox folder.

http://breckyunits.com/code/how_i_organize_my_dropbox


I have a system that works well for me, basically separating small test/experimental bits of code from code for customer projects. I'll talk about the layout of book code later.

I keep small test/experimental bits of code in sub-directories of top level directories labeled Java_stuff, Lisp_stuff, Scheme_stuff, Ruby_stuff, Python_stuff, etc. Each test/experiment is in a well named sub-directory. These small experiments are useful for both learning and for later reuse on real projects.

I keep each active customer project in a directory with sub-directories for documentation, code, and test data.

For work on books: similar to customer projects: sub-directories for source code, for figure files (OmniGraffle and exported vector PDF files), for code examples, and for Latex (or OpenOffice if I can't use Latex).

I also keep a temp directory for downloading, building, running, and perusing source code for projects that I read about on the web. I periodically delete stuff in temp that is older than a few weeks old.

Finally, not specifically for code: I use Google documents to make copious deployment notes which I use for reference for future projects.


BTW, I also use git for almost all of the materials in the parent comment. I use a very small managed VPS for my git repositories.

For extra backup (in addition to git remote repositories): I have a script that mounts a EBS volume on my always running EC2 instance, does an rsync to the EBS volume of almost everything but decrypted sensitive files, and then unmounts the EBS volume. EBS volumes are reasonably reliable.


I don't keep any snippets around on my machine - just have a knack for remembering how to get to a specific snippet via Google.

Each project gets its own directory that contains everything needed for that project (unless I have a shared framework, library, etc). All the projects are committed to a private SVN repository although I am taking a serious look at Git lately.


By snippets, I mean little bits of useful code or short scripts that I don't use frequently, but find myself reusing them regularly enough to keep them around. Generally, I don't keep these in version control, and as such, they're not posted online.

I might consider moving them all to using gists, but I'm not quite sure if that's ideal.


I have similar habits, which feel like a big time leak. I recommend git because I find the peer to peer model more elegant, but I've yet to use git collaboratively.


  $HOME/Projects/<Project Name>/
  $HOME/Miscellaneous/<Language>/<description/
  $HOME/College/{Fall, Spring} <year>/<class name>/{Lab, Project} #/
Which is all mirrored in a private svn repo I've got running on a VPN.


  ~/work/fooN
Where fooN are svn (possibly other) working directories.

My personal (at home) is slightly different cause I have a lot more stuff than just code revision controlled.

  ~/work/art/
  ~/work/src/
  ~/work/sys/
  ~/work/web/
  ~/work/words/
"sys" is /etc and other system files from various machines. "web" hearkens to the days when websites were static html and images. Probably should merge that with "src" someday

In src I have some directories such as "hints", "icons", "perl", etc. into which to stuff bits of things that don't deserve their own VCS repository.


~/Projects/ for what I'm building

Everything else is in my svn repo that I can access from anywhere with svn+ssh.

Recently, I've started putting code spippets that I think I will re-use in my Dropbox.


    ~/ ls dev/
    freelance  opensource  personal  slum
Fairly self explanatory, slum is for random one-off things that probably won't go anywhere.


I have a directory off the root FS for code I own, a directory off the root for each other IP holder and each person's code goes in their own directory.


~/projects : where I keep my personal projects

~/extern-projects : where i pull other projects from github and stuff, just to mess around with / bugfixes

~/src : where I store little scripts or test code, just a sandbox area to mess around.

~/test : i send testing tarballs here, basically anything I don't care too much about, as I empty this folder out periodically.


insufficiently

currently : master git repository for everything, something like ~/docs lots of breakdown of documentation more git repositories under : ~/docs/code/projects - stuff I am currently working on or using ~/docs/code/legacy_projects - stuff that I don't want to die or need for reference, but I've lost interest for one reason or another ~/docs/code/public_projects - mirrors of servers, portfolio pieces, videos, all sorts of things that other people can see

I've been flirting with mavenizing everything for some time, but I just can't seem to overcome the inertia of... current build process works, code needs to be written, deal with it later


~/Projects/ for important projects (i.e. not git clones of random GitHub projects, but major personal/work projects)

I don't have many other random code snippet things, but they generally go into Dropbox for easy storage.


  ~/dev -- projects I'm (semi-)actively hacking on
  ~/Repositories -- checkouts of dependencies and projects 
                    I'm tracking but not hacking
  ~/arc -- same as dev but for work


Just ~/p

~/p/slime ~/p/go ~/p/ccl ~/p/sbcl

In ~/p itself I'm putting some .el scripts, .txt, .bat, .sh, .cmd files for various updates (when going to the folder and doing "hg pull", "svn update", "git pull", etc. is not enough).


I have a "Playground" folder with a ton of randomly named projects in it. I like using the word "Playground" because then I don't feel guilty if I don't finish something...


~/<Project> for anything active, ~/Content/<Project> for anything I've stopped working on.


"/.../Desktop/project_name" contains all the files for that project. Every project has its own directory.


exactly the same way - a mess

The beauty of a hosted SCM (I use Bit Bucket) is that I only have to remember to "pull" when starting work on a project and "push" when finishing and it is all kept safe :)

I swap between about 4 or 5 machines here and at work so the chances of keeping it sane otherwise are low :)


Git.


That has no bearing on the organization of the directory tree of your code.

I already keep my projects (public and private) in version control (on GitHub).


What if you're also contributing to other projects that don't use git(hub)?


I use eclipse because it has support for a lot of the different languages I have to work with. So I organize my projects by language first under an eclipse workspace folder.

~/workspace/perl ~/workspace/erlang ~/workspace/cpp

Then inside each folder there is a project. And I either create them or import them using eclipse.

For projects that are large and require a large number of languages. I simply create it under the workspace directory. (i.e. ~/workspace/MyBigProject)

And from then I break it down into languages again along with other folder necessary for larger projects.

MyBigProject -> bin/ conf/ docs/ erlang/ perl/ sql/ web/

Then I tend to use the best possible layout for a project of that language. For example since I use CGI::Application a lot using perl, my perl folder uses the following structure:

    perl ->
        deps/ <-- cpan/other modules that are needed
        MyBigProject/ <--Namespace for project modules
        startup.pl <- mod_perl2 startup file
        templates/ <- HTML::Template templates...
   and MyBigProject breaks down like so:
        MyBigProject -> 
            DB/
            UI/
            (Other Modules)
and so on, the same goes for the erlang OTP:

    MyBigProject/erlang/ ->
        db/
        deps/
        ebin/
        Makefile
        src
and MyBigProject/web just holds all the html/javascript/css files for the WebUI.

And so on.


Was looking for this. I use a ~/workspace/ directory and was wondering where I picked up that notation. Organizing by language is an interesting idea too.


~/projects/PROJECT — my personal projects (no longer used);

~/projects/package-gen/dst/PROJECT — my personal projects in RPM package format, with automatic build system, various templates for new packages, repository of built binary and source packages;

~/work/PROJECT — work;

~/bin — various personal scripts and programs;

~/tmp — scratch, e.g. ~/tmp/1 or ~/tmp/foobar;

~/gtd/projects — various stuff, sorted by purpose, tag or/and date. Links from here to many other places;

~/gtd/income — various stuff, to be sorted;

~/examples — various working snippets;

/usr/share/bash-modules/ - various typical functions for bash scripts, e.g. "backtrace" or "..." (recently created as alternative to ~/examples/bash-..., see http://vlisivka.pp.ua/en/bash_modules ).

I use very simple tagging tool to speedup sorting, e.g. "s foo.tar.gz foo bar" will create two hard links to "foo.tar.gz" file in ~/gtd/projects/foo/ and in ~/gtd/projects/bar/ directories, and so on.

Currently, I use RPM packages only for my own projects, because they are easy to install/uninstall/upgrade, they contains documentation, changelog, and description, they are easy to verify or rebuild, and so on.


Can you post that 's' tool?

Sounds like it'd be really useful...


    appl/*/*.b
    module/*.m




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: