Giter Site home page Giter Site logo

docs's Introduction

docs

A collection of my docs, dot files, and anything else related to coding.

Slack docs Heroku docs Setup docs

Style docs

  • Modifier classes should be kept as small as possible

JS standards

  • Comment dividers, /** sdfdsf **/

frontend standards (eslint here)

React Component Guide

State

  • No duplicate or generated values in your state.
  • Your state should represent the absolute minimum amount of data

react app guide Testing

JS

No Classes

No Switch statements

Switch Cases in js were poorly designed. They not faster than other methods, also each case must have a break; at then end of it or it will cascade into the next case. This can produce unseens bugs that are very hard to reproduce and track down.

The better approach is to produce an object mapping of your 'cases' and 'results'. This has the added benefit of easily being passed around, dynamically generated, or externalized into a config file if it becomes very large. Lodash's _.result is excellent for this, providing pure valueand functional cases, as well as defaults.

const getColor = (name, default='#333')=>{
	const mapping = {
		red : '#c0392b',
		blue : '#2980b9',
		green : '#27ae60',
		rand : ()=>_.sample(_.values(mapping))
	};
	return _.result(mapping, name.toLower(), default)
};
getColor('Green'); //'#27ae60'
getColor('Maroon'); //'#333'

Use Arrow Functions

docs's People

Contributors

stolksdorf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.