some stuff
This commit is contained in:
53
code_lint.md
Normal file
53
code_lint.md
Normal file
@ -0,0 +1,53 @@
|
||||
# My coding style
|
||||
|
||||
For my years of programming in different language I sort of got a coding style in different language that I more or less follows.
|
||||
The problem is that I'm not really so consistent with it.
|
||||
|
||||
## Defining a scope
|
||||
|
||||
For Languages that uses Brackets {} or something similar to define their scope,
|
||||
the opening bracket should be on the same line as the definition and
|
||||
the closing bracket should be on a separate line.
|
||||
|
||||
for instance:
|
||||
|
||||
```c
|
||||
...
|
||||
|
||||
bool move(double x, double y){
|
||||
if(x - y < 0){
|
||||
x = y;
|
||||
return false;
|
||||
}
|
||||
y = x;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
...
|
||||
```
|
||||
|
||||
but, if the conditional statement before is on multiple line then the openning bracket should be on a new line.
|
||||
This help differientiate between the condition and the actual scope
|
||||
|
||||
for instance:
|
||||
|
||||
|
||||
```java
|
||||
...
|
||||
|
||||
boolean move(Vec2 position){
|
||||
if(position.blocked &&
|
||||
position.empty &&
|
||||
something.else())
|
||||
{
|
||||
position.setPos(x, y);
|
||||
return false;
|
||||
}
|
||||
this.position = position;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
...
|
||||
```
|
Reference in New Issue
Block a user