# Coding Conventions (Rules)

Every programming language, development environment, business, and person has their own opinion of how to write *readable* code. Without a set of rules, reading your colleague's code would be difficult. It is important to make code easy to read because someone else might need to use or improve it - and that's ok!

Most programmers have very specific rules for code style. Ours are simple:

* Variable and Function names will be *meaningful* and complete.
* Variable and Function names will only start with lowercase letters.
* Variables and Functions will be named using [**camelCase**](https://en.wikipedia.org/wiki/Camel_case)**.**
* Constants are written in all UPPERCASE letters.
* You will put spaces after commas, and around operators ( **`+ - * /`** ).
* *Always use 2 or 4 spaces to indent code blocks (our default is 2)*\
  (tabs are interpreted differently, depending on the text editor).\
  Example:\
  `function toCelsius(fahrenheit) {`\
  &#x20;   `return (5 / 9) * (fahrenheit - 32);`\
  `}`
* Always end single lines of code with a semicolon;
* Place opening brackets at the end of the current line, preceded by a single space.
  * Closing brackets are placed on their own line without leading spaces.\
    `for (i = 0; i < 5; i++) {      // Opening bracket`\
    &#x20;   `x += i;`\
    `}                              // Closing bracket`
* Hyphens are not permitted in names, use underscore instead.

For more on this topic:

{% embed url="<https://www.w3schools.com/js/js_conventions.asp>" %}

{% embed url="<https://en.wikipedia.org/wiki/Programming_style>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cs.brash.ca/unit-2/how-do-we-code/coding.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
