Programming 101: File Structures
Mục lục bài viết
Programming 101: File Structures
Each time I browse a GitHub repository or download some code files, I frequently come across some common file and folder names. On my quest to become a better programmer, I finally took the plunge to understand the purpose behind that organization.
Article Key Points
- What are File Structures?
- Why are File Structures important?
- Common File Structure Conventions
What are File Structures?
Generally speaking, a file structure is how you organize information on your computer. Regarding programming, the Broad Institute of MIT and Harvard describes a file structure as organized code with repeatability in mind. It makes it easier for anyone with access to your project to navigate project files. File structures build a framework that shows the purpose of elements by separating them into a hierarchy of folders.
Why are Programming File Structures Important?
A key advantage of file structures is that they make locating and accessing files easier. Having the ability to locate files allows developers to accomplish more work faster. File structures in programming allow developers to know where files are, when to use specific code, and locate associated results. Not only do file structures streamline productivity, but they also increase code consistency and shareability.
File Structure Examples
Standard File Conventions
- src/ (source): The files in this folder are meant to build and develop the project. This is where the original source files are located.
- dist/ (distribution): The files meant for production or public use are typically located in this folder. This folder could also be labeled public/ or build/.
- lib/(library): A collection of files, programs, routines, scripts, or functions that can be referenced in the programming code.
- bin/: These files that get added to your PATH when installed.
- test/: These files are the project’s tests scripts, mocks, etc.
- assets/: These files are static content like images, video, audio, and fonts.
- node_modules/: includes libraries and dependencies for JS packages used by the npm package manager.
Markdown Files
- README.md: This file contains information about the other files in a directory. It is usually a simple plain text file called README, Read Me, READ.ME, README.TXT, or README.1ST.
- LICENSE.md: This file shows you any rights given to you regarding the project. Alternative names include LICENSE or LICENSE.txt.
- CONTRIBUTING.md: This file gives developers guidelines for contributing to a project.
Common Conventions
- .gitignore: This file is used to specify the files meant to be ignored by Git.
- package.json: defines libraries and dependencies for JS packages (npm)
- package-lock.json: specific version lock for dependencies installed from package.json, (npm)
- composer.json: defines libraries and dependencies for PHP packages (composer)
- composer.lock: specific version lock for dependencies installed from composer.json (composer)
This article is just an overview; boundless file structures get more specific and dynamic depending on the programming language you’re using for your project. Take some time to research structures associated with your language of choice. Remember, friends, do or do not; there is no try. Happy learning!