Skip to content

Conventions #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open

Conventions #100

wants to merge 64 commits into from

Conversation

sDos280
Copy link
Contributor

@sDos280 sDos280 commented Jan 6, 2023

hi @electronstudio.
sorry for not pushing the conventions branch. I just forgot to work on it...

currently, I didn't refactor all the examples, but as I can see it, I will probably not work on them anymore. I don't have as much free time as I had in past...

sDos280 and others added 30 commits September 21, 2022 22:29
sDos280 and others added 19 commits September 24, 2022 14:51
stand the example to the new conventions
electronstudio#88

init_window(screenWidth, screenHeight, "raylib [core] example - 2d camera")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2D

Comment on lines +26 to +30
Some other conventions to follow:
- **ALWAYS** initialize all defined variables.
- **use TABS / 4 spaces**.
- Avoid trailing spaces, please, avoid them
- Avoid using **semicolon** as you can
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are linters and formatters for that. ruff, black and isort will be enough to not bothering with those rules.

- **use TABS / 4 spaces**.
- Avoid trailing spaces, please, avoid them
- Avoid using **semicolon** as you can
- Control flow statements always are followed **by a space**:
Copy link
Contributor

@pkulev pkulev Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange one, never saw that rule neither on production nor in open source projects. Why?
PEP8 says something like "don't write if-statements in one line"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair

- Avoid using **semicolon** as you can
- Control flow statements always are followed **by a space**:
```python
if condition : value = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have if-expressions for that.

value = 0 if condition else value

Or if it is initialization thing:

value = value or 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That isn't an "if statement" that is the ternary operator


for i in range(NUM_VALUES): print(i)
```
- All conditions checks are **always between parenthesis** but not boolean values:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that's big whaat.

  • Why always?
  • Why booleans are different?

50 and True will return 50. Should it be between parenthesis?

Copy link
Contributor Author

@sDos280 sDos280 Nov 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, as you see the conventions haven't really been reviewed by electrostudio so yeah they aren't perfect, feel free to fork my doing and implementing your conventions

p.s. and yeah the conventions aren't perfect because in the beginning they were made to mimic the raylib code style conventions but maybe following PEP 8 would be better...

@electronstudio electronstudio force-pushed the master branch 2 times, most recently from 568da0c to 22af403 Compare February 12, 2025 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants