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
- Host: GitHub
- URL: https://github.com/sendyhalim/naming-things
- Owner: sendyhalim
- Created: 2017-03-14T06:56:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-26T13:19:18.000Z (about 9 years ago)
- Last Synced: 2025-08-28T22:51:41.926Z (10 months ago)
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```