Skip to content

Commit c670714

Browse files
committed
Add functional programming conventions
1 parent cf9eaaa commit c670714

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

functional-programming/CONVENTIONS.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
When writing code, you MUST follow these principles:
2+
- Code should be easy to read and understand.
3+
- Keep the code as simple as possible. Avoid unnecessary complexity.
4+
- Use meaningful names for variables, functions, etc. Names should reveal
5+
intent.
6+
- Functions should be small and do one thing well. They should not exceed a few
7+
lines.
8+
- Function names should describe the action being performed.
9+
- Prefer fewer arguments in functions. Ideally, aim for no more than two or
10+
three.
11+
- Only use comments when necessary, as they can become outdated. Instead, strive
12+
to make the code self-explanatory.
13+
- When comments are used, they should add useful information that is not readily
14+
apparent from the code itself.
15+
- Properly handle errors and exceptions to ensure the software's robustness.
16+
- Use exceptions rather than error codes for handling errors.
17+
- Consider security implications of the code. Implement security best practices
18+
to protect against vulnerabilities and attacks.
19+
- Adhere to these 4 principles of Functional Programming:
20+
1. Pure Functions
21+
2. Immutability
22+
3. Function Composition
23+
4. Declarative Code
24+
- Do not use object oriented programming.

functional-programming/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Functional Programming Conventions
2+
3+
This conventions file provides guidelines for writing good functional code. The definition of "good" here is largely influenced by [Clean Code by Robert C. Martin](https://www.goodreads.com/book/show/3735293-clean-code) ([web archive in case of url rot](https://web.archive.org/web/20250127215242/https://www.goodreads.com/book/show/3735293-clean-code))
4+
5+
## Purpose
6+
7+
These conventions ensure that code is
8+
- simple
9+
- easy to understand
10+
- maintainable
11+
12+
## Use Cases
13+
14+
This convention is intended for use when writing code using functional paradigm
15+
16+
## Usage
17+
18+
[See How to Use These Conventions](https://github.com/Aider-AI/conventions#how-to-use-these-conventions)

0 commit comments

Comments
 (0)