Code Style Guide

The code style guide for all the programming languages that has been used on all of our applications.

General

Tab

1 tab = 2 indents

VS Code preference example

Variable Name

  • Use Snake case.

  • Start with lower and separate with underscore. Example, user_firstname.

  • The reason, is to make the variable name clear and can just glance at it to know for the variable is use for or belong to then using camel case.

  • There is some exception in Vue.js due to the framework.

Method Name

  • Use Camel case.

  • Always name it in vert, adverb, or start with these two.

  • If the method return a view such as from the Laravel Controller. It should be the view name instead.

PHP

Overall

Array

  • Always use brackets for array. Do not use array().

  • Always space after a comma.

  • If need a new line, comma need to be at the end of the above line, not in front.

  • No space before comma.

  • No left comma on array.

  • If the string is too long, the next value should start in new line.

String

  • If it's only a text string, you single quote.

  • If the string contain a variable, use double quote instead so it is possible to place variable inside the string without dot for concat.

  • The curly bracket can be used instead if the variables are put together without space.

Function

  • Always a space between function name and parameter.

  • Always a space between parameter and an open curly bracket.

HTML

PUG

Blade Template

Javascript

Vue.js

CSS/SCSS

MySQL

Last updated