How to start a new project

© 2020 Morgan C. Benton code4your.life

Steps to take

  1. Create a GitHub repo
    1. Good terse description
    2. Add README.md
    3. Appropriate .gitignore
  2. Clone the repo to your
    hard drive
  3. Initialize your project's
    dev environment
  4. Set up TDD tools and write/run a smoke test
  5. Begin TDD process
  6. Add-Commit-Push frequently

© 2020 Morgan C. Benton code4your.life

python demo

© 2020 Morgan C. Benton code4your.life

  1. Create a GitHub repo with Python .gitignore
  2. Clone the repo to your hard drive and cd into the directory
  3. Initialize a virtual environment in your project directory:
    python -m venv venv
  4. Activate the virtual environment:
    source ./venv/bin/activate (OSX/Linux)
    source ./venv/Scripts/activate (Windows)
  5. Setup testing:
    pip install pytest pytest-testmon pytest-describe pytest-watch
  6. Export installed package list (each time new package installed)
    pip freeze > requirements.txt
  7. git Add-Commit-Push
  8. Begin TDD process

javascript demo

© 2020 Morgan C. Benton code4your.life

  1. Create a GitHub repo with Node .gitignore
  2. Clone the repo to your hard drive and cd into the directory
  3. Initialize a new Node project:
    npm init (answer "jest" for testing command)
  4. Setup testing:
    npm install --save-dev jest
  5. git Add-Commit-Push
  6. 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.

  • 856