Skip to content

Replace "magic numbers" with IntDef #9

@Sternbach-Software

Description

@Sternbach-Software

A magic number is "a unique value with unexplained meaning or multiple occurrences which could (preferably) be replaced with a named constant" - Wikipedia.

There are many instances where a number is used as a case in a switch or if statement to specify which action should be done (e.g. if(action == 5) { //create note), and it is a practice that has been found to often introduce bugs and reduce code readability.

The preferred solution in Android is to replace it with an IntDef.

Here are some examples that need changing (some are links to function definitions, so all calls to that function need to change; likewise for variables):

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions