Files and Directories - Naming Conventions

Prerequisites

Terms

Directory
Equivalent to a folder on a file system. “Directory” sounds more nerdy.
Root Directory
The top folder of any given server “context”. On your local file system, the root directory is the top directory on your hard drive. For a website, it’s the top directory under a domain name.
Current Working Directory
Your current location in a command line application. a.k.a. Present Working Directory
Relative File Path
A partial path (there is no leading slash) that is relative to the current working directory. Example: images/pic1.png
Absolute File Path
A full path (starts with a leading slash) that points to the same location in a file system regardless of the current working directory. The leading slash make the path relative to the root directory. Example: /Users/tony/Documents

Warning: Absolute and relative paths have a slightly different definition in the context of HTML links (CPNT 260). Absolute paths are full URLs with protocol and domain information. Relative paths are all others, including links that start with a leading slash.

File naming conventions/guidelines

  • Files should be named consistently
  • Filenames should be short but descriptive (<25 characters)
  • Use alpha numeric characters when possible
  • Use underscores or hyphens instead of spaces
  • In general, use lower case characters. Note: exceptions include README files, DOCTYPEs, function constructors (not covered deeply in this course) and a few others.

Directory structure conventions

SAIT WBDV Fast Track

default directory structure for this program:

```
- /sait-wbdv
--- /_materials
--- /in-class
--- /assignments
--- /projects
```

Download a copy of this structure here: https://github.com/sait-wbdv/default-dirs

Static websites

```shell
- /css
--- /main.css (or styles.css)
- /images
--- /logo.png
- /js
----- /client.js
- /index.html
- /README.md
```

Project workspaces

A Git “repo” is really just a fancy folder, although, it’s important that you don’t create a repo inside another repo.

In this program, it’s recommended you create a dedicated “workspace” folder that will contain a flat list of repos (a.k.a. fancy folders) that you will be creating for lessons and assignments.

Example structure:

```
/projects
  /repo-1
    /index.html
    /css
      /reset.css
      /main.css (or styles.css)
    /js
      /app.js (or index.js)
    /README.md
  /repo-2
  /repo-3
  /etc
```