> For the complete documentation index, see [llms.txt](https://university-west.gitbook.io/programming-paradigms/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university-west.gitbook.io/programming-paradigms/program-creation-and-design/programming-style.md).

# Programming conventions

The general practices in computer programming, such as naming conventions, indentation, comments, and others, play a crucial role in ensuring code readability, maintainability, and overall quality. These practices may vary slightly depending on the programming language and the team's or project's guidelines, but there are widely accepted standards in the industry.

#### 1. Naming Conventions

* **Camel Case:** Used in languages like Java and JavaScript. Starts with a lowercase letter, and each new word starts with a capital letter, e.g., `myVariableName`.
* **Pascal Case:** Similar to Camel Case, but starts with an uppercase letter, e.g., `MyVariableName`. Common in C# for class and method names.
* **Snake Case:** Uses underscores to separate words, all lowercase, e.g., `my_variable_name`. Often seen in Python.
* **Kebab Case:** Uses hyphens to separate words, all lowercase, e.g., `my-variable-name`. Common in URLs and file names.

#### 2. Indentation

* **Spaces vs. Tabs:** Consistency is key. The choice between spaces and tabs for indentation is often a matter of preference or team standards. Python, for instance, strongly recommends spaces.
* **Indentation Level:** Typically, 2-4 spaces per indentation level or a single tab per level. Python enforces indentation as part of its syntax.

#### 3. Comments

* **Inline Comments:** Used for brief explanations or notes right next to the code. They should be concise and to the point.
* **Block Comments:** For detailed descriptions, often placed at the beginning of a function or a complex code block.
* **Documentation Comments:** Special comments that can be processed into documentation, e.g., Javadoc in Java or docstrings in Python.
* **Avoid Obvious Comments:** Comments should explain the "why" rather than the "what". Avoid stating what is obvious from the code.

#### 4. Code Structure

* **Consistent Bracing Style:** Whether you use the "Egyptian" style where the opening brace is on the same line as the statement, or the "Allman" style where the opening brace is on the next line, consistency is key.
* **Logical Grouping:** Group related lines of code together, and separate different sections logically.
* **Limit Line Length:** Aim for a reasonable line length, like 80-120 characters, for better readability.

#### 5. File and Directory Structure

* **Organize Logically:** Group related files in directories. Naming should reflect the content or purpose.
* **Separate Code from Resources:** Keep code files separate from resources like images, data files, etc.

#### 6. Other Best Practices

* **Use Meaningful Names:** Choose names that reflect the purpose of the variable, function, class, etc.
* **Avoid Deep Nesting:** Deeply nested code can be hard to read and maintain. Aim to simplify complex conditions or loops.
* **Consistent Syntax:** Be consistent in your use of syntax elements like commas, semicolons, etc.

By adhering to these general practices, developers can create code that is easier to understand, maintain, and collaborate on. It's also essential to adapt to and respect the coding standards of the specific project or team you are working with.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://university-west.gitbook.io/programming-paradigms/program-creation-and-design/programming-style.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
