Skip to content

Project best practices

Dan BROOKS edited this page Oct 15, 2017 · 13 revisions

This project is an ongoing hobby for over 12 years. I transitioned the business logic to hapi.js (previously PHP then Node.js with Express) web application frameworks. This is a living example of how to add new features to legacy code while avoiding a complete re-write due to my architectural choices to use small REST components and now the UI is being refactored to use React.js latest.

To showcase code choices for employers and students I have documented some recent highlights:

React.js v16 sample code

  1. Component lifecycle methods
    • UI allows the sort order to be changed causing React components to update

Node.js v8

  1. Promisify core modules
    • Avoid callbacks

ES2017 sample code

  1. Async and many promises
    • Avoid blocking code

ES2015 sample code

  1. Flat promise chain

    • Avoid deep nesting anti-pattern
  2. Curried function

    • Avoid too many arguments
  3. Environment variables

    • Avoid revealing secrets in public repository
  4. Dependency injection

    • Avoid hardcoded constants

CI

  1. Unit tests for ES2017 and React.js run for every commit and pull request Linux and Windows CI badges
    • Avoid breaking existing behaviour
  2. Follow best practices with CI services such as Code Climate and Better Code badges
    • Avoid committing buggy code

CSS3

  1. CSS Grid to structure columns
    • Avoid CSS hacks using flex box or floats