Using your local language is a great idea because domain naming is easier. Not
TL;DR: Stick to English. Always.
-
Polymorphism
-
Cultural gaps
-
Mixed Code
-
Syntactic Errors
-
Write in English
-
Rename Domain Concepts to English
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.
const elements = new Set();
elements.add(1);
elements.add(1);
echo elements.size() yields 1
// This is the standard set
var moreElements = new MultiConjunto();
// You defined a multiset in Spanish
// because you are extending the domain
moreElements.agregar('hello');
moreElements.agregar('hello');
// 'agregar' is the Spanish word for 'add'
echo moreElements.size() yields 2 // Since it is a multiset
// Elements and moreElements are NOT polymorphic
// You cannot exchange their implementation
class Person {
constructor() {
this.visitedCities = new Set();
}
visitCity(city) {
this.visitedCities.add(city);
// Breaks if you change the set (expecting ‘add()’)
// with a MultiConjunto (expecting ‘agregar()’)
}
}
const elements = new Set();
elements.add(1);
elements.add(1);
echo elements.size() yields 1
// This is the standard set
var moreElements = new MultiSet();
// You defined a multiset in English
moreElements.add('hello');
moreElements.add('hello');
echo moreElements.size() yields 2 // Since it is a multiset
// elements and moreElements are polymorphic
// You can exchange their implementation anytime
[X] Automatic
Most IDEs and linters have a thesaurus.
We can search for foreign words.
- Readability
Don't mix Non-English domain words with English primitives.
Even when Mapping your real-world entities, use plain English.
Photo by Anna Vander Stel on Unsplash
A programming language is a tool that has a profound influence on our thinking habits.
Edsger Dijkstra
Software Engineering Great Quotes
This article is part of the CodeSmell Series.