How do you organize source code on your computer?

I'd be curious to see how everyone organizes their source code.

Let's see some screenshots or terminal dumps of your set up.

Here's what I've been doing for the last 5 or 6 years:

Source code layout

I like to organize my code by what it's used for rather than by language.

I've been a freelance developer for about 20 years and inside of those folders are hundreds of projects ranging from Visual Basic 6 from the mid 1990s to more recent projects written in Flask, Rails and Phoenix.

Did you find this post useful? Show some love!

Below is how my sources are organized (for personal codes)

  1. public sources - GitHub
  2. private source - GitLab
  3. Playground - throwaway

sources
(Please ignore the poo.πŸ’© file.)


GitHub has another top level directories, "Docker", "Aspnet", etc by technology.

I don't differentiate much by languages though.
I've been using above set up last 3 years and been working great.

throwaway is where all my one-offs or test/useless code are located.

I have a different structure for work as I have to follow the conventions at work.

I had no idea you could use emojis in filenames.

var mind = "blown";

Apparently POO is an OOP language.

  • Day job:
    ~/Projects/CompanyName/ProjectName

  • Personal serious side projects or regular open-source contribution:
    ~/Projects/Personal/ProjectName

  • Practice non-serious side projects:
    ~/Projects/Practice/TechnologyName/ProjectName

  • Some open-source apps/scripts that I use and tinker with or have to self-host:
    ~/Projects/Applications/ProjectName

  • One-off scripts and POCs:
    ~/Projects/tmp

I have a Prog folder where there are all my repos localy that are mainly scripts or stuff that later I move on /var/www where I have the webserver or my vagrant machines.
Compared to you I am a bit disorganized.

For contracts and courses I use folders on external drives just to be sure that they are backup with my Nextcloud instance.

Keep in mind, I didn't start out like this.

The legacy folder alone as of today has 102 projects. That directory structure was slowly built up over many years.

Ben Halpern DEV.TO FOUNDER

Hey there, we see you aren't signed in. (Yes you, the reader. This is a fake comment.)

Please consider creating an account on dev.to. It literally takes a few seconds and we'd appreciate the support so much. ❀️

Plus, no fake comments when you're signed in. πŸ™ƒ

~/dev is where I dump everything since that's an easy path to cd to.

I should probably care more than this, but it works for now.

Exactly what I do. I let GIT handle everything for me.
The only exception: In dev is a directory called Clones, and as the name tells: I Dump all the cloned public repositories in here.

Most of my projects are in a ~/Projects dir. I have a bunch of shell scripts in an another dir that does not make much sense (~/Other/Scripts)... I should move this dir but it has been there for years so... it's tradition now I guess πŸ˜€

I try to keep my ~/Projects dir tidy by removing any project that I'm not actively working on, since most of them are either on GitHub or my Gitea instance anyway.

Normally I throw everything in a development folder on any machine I'm working on.

Not every project is on every machine, these are just my desktop projects.

listing

One folder for one project. My mobile projects are on the MacBook.

Private projects go on Bitbucket, public projects go on GitHub.

~/Projects
    |- archived
    |- ongoing
    |- tutorials

ongoing is where I have the projects that I'm currently (or I've reasonably recently been) working on.

archived is where I move my projects after I abandon them. I try to be honest with myself and move projects from ongoing to here when I haven't worked on them in a few weeks and it's unlikely that I will take them up in the next few days. Also, sometimes I move projects from archived to ongoing if I decide to resurrect them.

tutorials is where I store the code I write following tutorials. I have a special consideration for those because usually when I'm learning something new and I follow a tutorial, I create a project with all the examples and stuff, that is handy to review when I'm working on a project with that stuff.

  • ~/CompanyName/ProjectName # Day Jobs
  • ~/Customer/CompanyName/ProjectName # Legacy Jobs
  • ~/Prototype/ProjectName # My Experiments
  • ~/GitHub/ProjectName # Downloaded Projects
  • ~/bin/ScriptName # My Own CLI Scripts
  • ~/Tutorial/ThemeName # Courses
  • ~/Documents # Contracts
  • ~/Downloads # Unprocessed Downloads
  • ~/Dropbox # Shared Configurations

I inserted some directories into CDPATH for easy use.

For coding projects I have to directories:

  • ~/Projects/
  • ~/Experiments/

Most of the projects in both directories are Python projects and under version control, so am not grouping them more granularly.

I've had many organizing rules among the years, now I'm back at folders per main project, because I'm learning and switching a lot.

img

I removed all my old projects (windows and php), and I started a clean slate, on a new laptop.

Interesting to see diff. structures :D

In my case, a high-level structure contains each company and own projects under "personal".
And inside that, each project folder.

EG:
~/Projects/personal
~/Projects/companya
~/Projects/companyb
~/Projects/companyb/projectabc

Inside each project folder, also some structure, but can vary depends on the technology used:
EG:
~/Projects/companyb/projectabc/_DOCS - Project documentation, dumps, csv files, whatever needed.
~/Projects/companyb/projectabc/www - root

I'm on this bandwagon, but without the top level projects dir. I find it better to have my current company in my home folder, and have an archive which I ship the previous company to when I finish.

I have a Developer folder in my home directory.
I put all my code into the Developer folder. No other folders have project codes.
Folder name of the project will be the same as git repo name (only lowercase and dashes. no underscores).

I use GitHub for public sources and GitLab for private sources.

I have same structure for work

I like the idea of having everything on my home.

(~ is where ❀️ is)

Any kind of ~/Developer or ~/Projects would be a good fit for me. However, in the last year I settle on ~/Code. And since then I store all my repos on that folder. And I try to keep only projects that I am working on. I use GitHub, GitLab and Bitbucket for store all of them remotely.

I have three exceptions though. First, my dotfiles repo is at ~/.dotfiles. Second, a spells repo is at .spells which contains some shell scripts.

The third exception is anything that I might use for learning purposes. I store those at ~/Desktop.

~/code/fun/[project]
~/code/work/[client]/[project]

Because we use a project management software at work. I break it down by the following:

  • What department is the user? (I work in a college).
  • What is the Project Management Number?

I started using Git for changes, but I should be getting back to using it more regularly than I have.

All my projects are on ~/ except for future pull requests on ~/Forks.

Due to the limitation of windows path length (260) and an insane vendor, my source is at C:[source_control_project]

I have everything under one directory and then all arraged by client/project/

well, I Want It That Way - Backstreet Boy

Classic DEV Post from Jun 14

Negotiating is hard.

It was a delight to chat about job offers and negotiating with Gloria Kimbwala and Jessica Rose!

READ POST
Follow @amycodes to see more of their posts in your feed.
Nick Janetakis
I'm a full stack web developer who has been freelancing for the last 20 years. I write about everything from development to production to developer oriented business tips.
More from @nickjj
Would Socrates Use Docker Today?
#docker #beginners #learning #productivity
Using WSL and MobaXterm to Create a Linux Dev Environment on Windows
#productivity #webdev #beginners #windows
Trending on dev.to
Automating My Newsletter Generation with MailChimp, Google Sheets, and AWS Lambda
#aws #serverless #productivity #showdev
How to use PHPUnit for Laravel
#php #laravel #phpunit #beginners
Memoization in a Nutshell
#explainlikeimfive #beginners #javascript
Lessons from releasing a personal project as a commercial product
#beginners #startup #showdev #career
What tools are in your toolbox?
#discuss #productivity #career #beginners
Code camp or self-learning
#discuss #productivity
Quick Tip: Write an HTTP server in Dart πŸ’»
#tips #dart #http #beginners
Untangling Nested Code
#practices #programming #beginners