Coding Standards - pmvdbijl7/matching-app GitHub Wiki
To ensure that the programming style, procedures and methods of the programming language are the same throughout, we have set up a number of coding standards. These are, as it were, collections of rules and guidelines to keep the code clear and consistent. Adhering to these coding standards will increase the quality of your code and make it easier to maintain. Besides that, it can save you a lot of time and it is easier if you work with a team on your code in the future.
HTML
When creating/maintaining an HTML file, you should adhere to the following coding standards:
- Always declare the document type as the first line in your document:
<!DOCTYPE html>
. - Always use lowercase element and attribute names.
- Use double quotes for attribute values:
<p class="highlight">
. - Always specify an alt attribute for images.
- Add blank lines to separate large or logical code blocks.
- Always use the
/
to close empty html elements:<meta charset="utf-8" />
.
CSS
When creating/maintaining a CSS file, you should adhere to the following coding standards:
- Use soft-tabs with a four space indent.
- Use double quotes.
- Put spaces after
:
in property declarations. - Put spaces before
{
in rule declarations. - Use hex color codes
#000
unless usingrgba()
. - Use one line per property declaration.
- Always follow a rule with one line of whitespace.
- Make sure that the CSS code is in sequence of the HTML structure of a page. So start with the header, then the main and then the footer etc..
- Use variables as much as possible so that if you want to adjust a base color you only have to do it once.
JavaScript
When creating/maintaining a JavScript file, you should adhere to the following coding standards:
- Make sure that all naming conventions are always written in camelCase.
- Always use the arrow function (
() => {}
) instead of a normal function (function() {}
) when it does not need function name. - Use constants (
const
) andlet
's everywhere instead of variables (var
's).
Folder- / Filenames
- Folders should always be spelled with "snake_case".
- Files should always be spelled with "camelCase".