mirror of
https://github.com/kettanaito/naming-cheatsheet.git
synced 2025-08-16 17:41:17 +02:00
Updates README
This commit is contained in:
19
README.md
19
README.md
@ -41,7 +41,8 @@ const shouldPaginatize = (postsCount > 10) // Made up verbs are so much fun!
|
||||
|
||||
/* Good */
|
||||
const postsCount = 5
|
||||
const shouldDisplayPagination = (postsCount > 10)
|
||||
const hasPagination = (postsCount > 10)
|
||||
const shouldDisplayPagination = (postsCount > 10) // alternatively
|
||||
```
|
||||
|
||||
## Avoid contractions
|
||||
@ -217,6 +218,22 @@ link.addEventListener('click', handleLinkClick)
|
||||
|
||||
A domain that a function operates on.
|
||||
|
||||
A function is often an action on *something*. It is important to state what is its operable domain, or at least an expected data type.
|
||||
|
||||
```js
|
||||
/* A pure function operating with primitives */
|
||||
function filter(predicate, list) {
|
||||
return list.filter(predicate)
|
||||
}
|
||||
|
||||
/* Function operating exactly on posts */
|
||||
function getRecentPosts(posts) {
|
||||
return filter(posts, (post) => post.date === Date.now())
|
||||
}
|
||||
```
|
||||
|
||||
> Note that language-specific assumptions may allow to ommit the context in some cases. For example, in JavaScript it is common that `filter` operates on Array. Adding explicit `filterArray` would be unnecessary.
|
||||
|
||||
---
|
||||
|
||||
## Prefixes
|
||||
|
Reference in New Issue
Block a user