mirror of
https://github.com/labs42io/clean-code-typescript.git
synced 2024-11-23 05:34:04 +00:00
TODO comments.
This commit is contained in:
parent
07c68cbe9f
commit
f0ba673e71
28
README.md
28
README.md
|
@ -2568,3 +2568,31 @@ class Client {
|
|||
```
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
### TODO comments
|
||||
|
||||
When you find yourself that you need to leave notes in the code for some later improvements,
|
||||
do that using `// TODO` comments. Most IDE have special support for those kind of comments so that
|
||||
you can quickly go over the entire list of todos.
|
||||
|
||||
Keep in mind however that a *TODO* comment is not an excuse for bad code.
|
||||
|
||||
**Bad:**
|
||||
|
||||
```ts
|
||||
function getActiveSubscriptions(): Promise<Subscription[]> {
|
||||
// ensure `dueDate` is indexed.
|
||||
return db.subscriptions.find({ dueDate: { $lte: new Date() } });
|
||||
}
|
||||
```
|
||||
|
||||
**Good**
|
||||
|
||||
```ts
|
||||
function getActiveSubscriptions(): Promise<Subscription[]> {
|
||||
// TODO: ensure `dueDate` is indexed.
|
||||
return db.subscriptions.find({ dueDate: { $lte: new Date() } });
|
||||
}
|
||||
```
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
Loading…
Reference in a new issue