An open API service indexing awesome lists of open source software.

https://github.com/sendyhalim/naming-things

Guidelines for naming things + reasonings, coding style guide, etc
https://github.com/sendyhalim/naming-things

Last synced: 4 months ago
JSON representation

Guidelines for naming things + reasonings, coding style guide, etc

Awesome Lists containing this project

README

          

# Naming things
Just my convention for naming things in code

## Variables
### Iterable
Use plural for iterable data type such as `Array` and `List`

Good
```
posts
users
```

Bad
```
post
user
```

### Map / Dictionary
Use `By` format for `Map` / `Dictionary` type

Good
```
// If we supply email as key, we will get a user
userByEmail

// If we supply product type as key, we will get an iterable products
productsByProductType
```

Bad
```
users
user
products
product
```

## Comments
- Always use capital letter to start a new sentence
- Add one space between comment marker and the comment itself

Good
```
// This is a comment.
// Another comment.
```

Bad
```
//This is a comment
// this is a comment
```

## File Nodes
Use hyphen `-` or underscore `_` to separate words

Never use
- space, makes it harder for autocompletion in terminal
- camelCase, macOS is not case sensitive.

Good
```
some-file.txt
some_file.txt
```

Bad

```
someFile.txt
some file.txt
```

## Urls
Use `-` to separate words

Good

```
http://example.com/some-example/post
```

Bad

```
http://example.com/some_example/post
http://example.com/some example/post
```