Code Monkey home page Code Monkey logo

dev-best-practices's Introduction

Barrel Best Practices() {

The Barrel approach to coding websites..

๐Ÿ“š Table of Contents


Formatting Guidelines for this document.


๐Ÿ“ Goals and Questions You Should Ask Yourself For Every Project

  1. Maintainability
  • is this going to make sense in 3 months?
  • what can I document now, to save time later?
  • how can I simplify this?
  1. Readablity
  • contributes to #1
  • are my teammates going to understand this?
  • what can I do to help my partner use this to their advantage?
  1. Flexibility
  • can I use this on other projects?
  • can I use this elsewhere within your current project?
  • what if this needs to change later?
  • what pieces can I abstract from this piece of code?
  1. Speed
  • what are the performance impacts of this code?

๐Ÿ“ General Practices

All projects regardless of the langauges and technologies used have a few common rules and best practices to follow. Please review the individual topics above for more specific cases.

String Manipulation

When outputting strings from within code, be sure to use string formatting syntaxes to allow for better readability. See the following code samples.

PHP

$string_formatted = sprintf("Welcome, %s. Today is %s", $username, date('Y-m-d'));
echo $string_formatted;
// or to output immediately...
printf("Welcome, %s. Today is %s", $username, date('Y-m-d'));

JS โ€” javascript has no native string formatting methods but several node modules exist

using js-string-format python clone

var string_formatted = 'Welcome, {0}. Today is {1}'.format([data.username, new Date().toString()])

using sprintf php clone

var string_formatted = sprintf("Welcome, %s. Today is %s", data.username, new Date().toString());

Documentation

All code should use a commenting syntax that is parsable and standard. Most of the comment-parsers utilize a java-doc-style syntax. For php, this is phpdoc; for javascript, this is jsdoc; for java, this is javadoc; and for ruby, this is rubydoc. See Documentation Guidelines for more details.

Attribution

All code should be attributed to "Barrel" unless imported from an existing project. That is to say, you should never include yourself as an author unless you wrote something at your leisure outside of Barrel for inclusion in a project. This includes all files such as stylesheets, javascript, and template files. We have a vast git history to know who wrote what.

An example of such file header from WordPress:

/*
Plugin Name: WooCommerce Fulfillment
Plugin URI: http://www.woothemes.com/woocommerce/
Version: 1.0
Description: Add custom fulfillment support to WooCommerce.
Author: Barrel
Author URI: http://barrelny.com/
Text Domain: woo-fulfillment
*/

PHP or Javascript:

/**
 * This is a comment block in php or javascript
 * @author BarrelNY
 */

This includes any @author comment.


๐Ÿ“ Production Basics

  • All production code should produce assets that are fully compiled or minified and concatenated. See the Javascript guide for specific approaches towards including scripts.
  • Limit usage of any framework and configure any frameworks to use as much code as is needed such as only including the components of bootstrap that will be used for your project.

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.