Skip to content

Commit

Permalink
Add some guidelines on naming
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy committed Feb 6, 2024
1 parent 98e8b3a commit 6fc50ef
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pages/developers/architecture.md
@@ -1,5 +1,5 @@
---
layout: default
title: Architecture
parent: Developers Corner
parent: Developers
---
2 changes: 1 addition & 1 deletion pages/developers/code-quality.md
@@ -1,7 +1,7 @@
---
layout: default
title: Code Quality
parent: Developers Corner
parent: Developers
---

# Code quality
Expand Down
2 changes: 1 addition & 1 deletion pages/developers/debugging.md
@@ -1,5 +1,5 @@
---
layout: default
title: Debugging
parent: Developers Corner
parent: Developers
---
2 changes: 1 addition & 1 deletion pages/developers/development-principles.md
@@ -1,7 +1,7 @@
---
layout: default
title: Development Principles
parent: Developers Corner
parent: Developers
---

# Development Principles
2 changes: 1 addition & 1 deletion pages/developers/how-to-contribute.md
@@ -1,7 +1,7 @@
---
layout: default
title: How to contribute
parent: Developers Corner
parent: Developers
nav_order: 1
---

Expand Down
2 changes: 1 addition & 1 deletion pages/developers/index.md
@@ -1,6 +1,6 @@
---
layout: default
title: Developers Corner
title: Developers
nav_order: 4
has_children: true
---
51 changes: 51 additions & 0 deletions pages/developers/naming.md
@@ -0,0 +1,51 @@
---
layout: default
title: Naming
parent: Developers
---

# Naming

Most of the following conventions, suggestions and recommendations are derived from the books linked in the References
Section.

## General

> Your code is for a human first and a computer second. Humans need good names.
> - Martin Fowler
> There are only two hard things in Computer Science: cache invalidation and naming things.
> - Phil Karlton
## Understandability

### Use accurate parts of speech

| Identifier Type | Parts of Speech | Examples |
|-----------------|-------------------------------------------------------------|----------------------------------------------|
| `Classes` | Nouns or noun phrases | `AdaptationSet`, `Representation` |
| `Variables` | Nouns, noun phrases, or linking verb and subject complement | `adaptationSet`, `activeStream`, `isPlaying` |
| `Methods` | Verb, verb phrases, or linking verb and subject complement | `reset()`, `checkConfig()`, `hasVideoTrack` |

## Include units

Several properties in the DASH specification require units such as the `bitrate` or the `duration` of a segment
download.
Variables dealing with these values **shall** contain units, for instance:

* `bitrateInKbit` instead of `bitrate`
* `downloadDurationInMilliseconds` instead of `downloadDuration`

## Booleans

Names of `boolean` variables and methods that return a `boolean` should explicitly indicate the return type. Their names
should either be a linking verb or a subject complement. Do not use names that can be interpreted as non-boolean concept.
Examples:

* `isPlaying` instead of `playing`
* `hasVideoTrack()` instead of `videoTrack()`

## References

1. Naming Thins by Tom Benner
2. Clean Code: A handbook for agile Software craftsmanship by Robert C. Martin

0 comments on commit 6fc50ef

Please sign in to comment.