Code Smell 128 – Non English Coding

Using your local language is a great idea because domain naming is easier. Not

TL;DR: Stick to English. Always.

Problems

Polymorphism
Cultural gaps
Mixed Code
Syntactic Errors

Solutions

Write in English
Rename Domain Conce…


This content originally appeared on DEV Community and was authored by Maxi Contieri

Using your local language is a great idea because domain naming is easier. Not

TL;DR: Stick to English. Always.

Problems

  • Polymorphism

  • Cultural gaps

  • Mixed Code

  • Syntactic Errors

Solutions

  1. Write in English

  2. Rename Domain Concepts to English

Context

All programming languages are written in English.

Unless for a few failed experiments during the 90's all modern languages use English for their primitives and their frameworks.

if you wanted to read or write in medieval Europe, you had to acquire a new language at the same time. Writing meant Latin.

This is true for programming languages nowadays.

I am not a Native English speaker.

My code (tries to be) in English.

Sample Code

Wrong

const elements = new Set();

elements.add(1);
elements.add(1);

elements.size() = 1 
//This is the standard set

var moreElements = new MultiConjunto();
//We defined a multiset in Spanish
//because we are extending the domain

moreElements.agregar('hello');
moreElements.agregar('hello');
//'agregar' is the Spanish word for 'add'

moreElements.size() = 2 //Since it is a multiset

//elements and moreElements are NOT polymorphic
//I cannot exchange their implementation

Right

const elements = new Set();

elements.add(1);
elements.add(1);

elements.size() = 1 
//This is the standard set

var moreElements = new MultiSet();
//We defined a multiset in English

moreElements.add('hello');
moreElements.add('hello');

moreElements.size() = 2 //Since it is a multiset

//elements and moreElements are polymorphic
//I can exchange their implementation anytime

Detection

[X] Automatic

Most IDEs and linters have a thesaurus.

We can search for foreign words.

Tags

  • Readability

Conclusion

Don't mix Non-English domain words with English primitives.

Even when Mapping your real-world entities, use plain English.

More Info

Credits

Photo by Anna Vander Stel on Unsplash

A programming language is a tool that has a profound influence on our thinking habits.

Edsger Dijkstra

This article is part of the CodeSmell Series.


This content originally appeared on DEV Community and was authored by Maxi Contieri


Print Share Comment Cite Upload Translate Updates
APA

Maxi Contieri | Sciencx (2022-04-09T01:35:59+00:00) Code Smell 128 – Non English Coding. Retrieved from https://www.scien.cx/2022/04/09/code-smell-128-non-english-coding/

MLA
" » Code Smell 128 – Non English Coding." Maxi Contieri | Sciencx - Saturday April 9, 2022, https://www.scien.cx/2022/04/09/code-smell-128-non-english-coding/
HARVARD
Maxi Contieri | Sciencx Saturday April 9, 2022 » Code Smell 128 – Non English Coding., viewed ,<https://www.scien.cx/2022/04/09/code-smell-128-non-english-coding/>
VANCOUVER
Maxi Contieri | Sciencx - » Code Smell 128 – Non English Coding. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/09/code-smell-128-non-english-coding/
CHICAGO
" » Code Smell 128 – Non English Coding." Maxi Contieri | Sciencx - Accessed . https://www.scien.cx/2022/04/09/code-smell-128-non-english-coding/
IEEE
" » Code Smell 128 – Non English Coding." Maxi Contieri | Sciencx [Online]. Available: https://www.scien.cx/2022/04/09/code-smell-128-non-english-coding/. [Accessed: ]
rf:citation
» Code Smell 128 – Non English Coding | Maxi Contieri | Sciencx | https://www.scien.cx/2022/04/09/code-smell-128-non-english-coding/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.