DEV Community

Cover image for TL;DR: Code ergonomics
András Tóth
András Tóth

Posted on


TL;DR: Code ergonomics

When you have competing conventions it can help to choose to check which convention has better ergonomics.

I am going to provide my own definition (another definition of code ergonomics).

Code ergonomics is everything beyond the solution to a product problem: it is syntax highlighting, readability of variable names, easy-to-understand small functions, meaningful composition, great file names, etc.

Ergonomics also means productivity.

Now let's see a real-world example.

The index.js convention vs. "smurf-naming"

Let's say your architect made a decision to neatly put the most important code into the index.js (or .php, .ts, whatever) file of a descriptive folder, i.e. controllers/publish-draft/index.js

Importing it into another file would be very neat:

import { PublishDraftController } from 
Enter fullscreen mode Exit fullscreen mode

Now compare this with the file, same controller but smurf-named:

Importing it and it looks like someone stammering:

import { PublishDraftController } from
Enter fullscreen mode Exit fullscreen mode

Clearly first version is the winner, right?


When you code you only look at import statements once to make sure you imported the right thing (if there are several entities with the same name). On the other hand you are going to very frequently read the tabs of your IDE, and the name of files in test results and so on.

Take a look at this:

Image description

Which one do you think is more informative?


When you make decisions keep the IDE you and your colleagues use in mind. The code that plays nicely with it will also increase the productivity of your team.

(Art was generated by MidJourney AI)

Top comments (1)

aarone4 profile image
Aaron Reese

For another example from RDBMS world. is the primary key of the Parent table.
Child.Parent_id is the foreign key to the Parent table on the Child table.

.id is always the PK, _id is always the FK.