How to start a new project
© 2020 Morgan C. Benton code4your.life
Steps to take
- Create a GitHub repo
- Good terse description
- Add README.md
- Appropriate .gitignore
- Clone the repo to your
hard drive - Initialize your project's
dev environment - Set up TDD tools and write/run a smoke test
- Begin TDD process
- Add-Commit-Push frequently
© 2020 Morgan C. Benton code4your.life
python demo
© 2020 Morgan C. Benton code4your.life
- Create a GitHub repo with Python .gitignore
- Clone the repo to your hard drive and cd into the directory
- Initialize a virtual environment in your project directory:
python -m venv venv - Activate the virtual environment:
source ./venv/bin/activate (OSX/Linux)
source ./venv/Scripts/activate (Windows) - Setup testing:
pip install pytest pytest-testmon pytest-describe pytest-watch - Export installed package list (each time new package installed)
pip freeze > requirements.txt - git Add-Commit-Push
- Begin TDD process
javascript demo
© 2020 Morgan C. Benton code4your.life
- Create a GitHub repo with Node .gitignore
- Clone the repo to your hard drive and cd into the directory
- Initialize a new Node project:
npm init (answer "jest" for testing command) - Setup testing:
npm install --save-dev jest - git Add-Commit-Push
- Begin TDD process
Explaining the steps
© 2020 Morgan C. Benton code4your.life
GitHub: Description
Potential audiences:
- Potential Employers or Teammates
- Your classmates or other coders
- Your instructor
Goal: Capture and highlight the key GOALS of the repo,
not necessarily what your program actually does,
but it's good if you can do both
Examples:
- BAD: A FizzBuzz program
- GOOD: A FizzBuzz demo of TDD with python and pytest
© 2020 Morgan C. Benton code4your.life
GitHub: .gitignore
The .gitignore file is a list of file and directory names (one per line) that should be ignored by git when you run commands like `git add`. These files and folders will NOT be added to your git repo.
Generally these are files/folders that other people would NOT need if they wanted to clone and run your project.
Python Examples
.pytest_cache
__pycache__/
venv/
JS Examples
node_modules/
logs/
coverage/
© 2020 Morgan C. Benton code4your.life
cloning the repo
It is extremely important to keep your project files in a logical and organized location on your hard drive.
- Create a `dev` folder where you always clone repos:
- /Users/yourusername/dev (OSX)
- C:\Users\yourusername\dev (Windows)
- Make sure there are no spaces in the file pathname
- Do NOT clone a repo inside of another repo
© 2020 Morgan C. Benton code4your.life
setting up the
dev environment
The goal here is to:
- Create an isolated, self-contained space to store the files in your project
- Make sure ALL of the files in your project are inside of your git repo
- Setup a space where 3rd party packages necessary for your project can be installed locally
© 2020 Morgan C. Benton code4your.life
Writing and running a smoke test
The goal here is to:
- Make sure that you've setup your dev environment correctly
- Make sure that your testing environment works
© 2020 Morgan C. Benton code4your.life
frequent
commits
The goal here is to:
- Keep your local project directory in sync with your remote git repo
- Protect yourself so that even if your computer dies, your project is not lost
- Enable other people to more easily collaborate with you
Each time you complete a small piece, it's a good idea to add those changes and commit them.
© 2020 Morgan C. Benton code4your.life
~$ git add .
~$ git commit -m "added fizz test"
~$ git push
summary
Following this procedure for creating a new project will put you on the right path to a smoother development process.
Although the details will differ, you can/should use the same process for pretty much any programming language.
Happy coding!
© 2020 Morgan C. Benton code4your.life
How To Start A New Project
By Morgan Benton
How To Start A New Project
The requirements and steps for creating a new programming project.
- 906