6

Is there a translation that means something similar as it does in English?

In my case I need that this was in the Informatic Sciences field, you can found the expression as:

  • boilerplate code
  • boilerplate project
3
  • 1
    A primera vista iba a decir plantilla, pero así se pierde la distinción entre template y boilerplate del inglés (aunque no hay por que todas las distinciones se conserven entre idiomas). Quizás código repetitivo, código predefinido, código esencial depende del contexto (pero cada uno de estos términos sería un pelín más específico que el inglés) Commented Jan 22, 2016 at 3:12
  • 1
    Código predefinido me parece la mejor opción. En efecto, no es exactamente el mismo significado, pero creo que se puede usar en muchos casos.
    – Gorpik
    Commented Jan 22, 2016 at 8:57
  • 1
    Linguee is a great source for translating terms in context. Código repetitivo appears a couple of times there.
    – Yay
    Commented Jan 22, 2016 at 10:04

3 Answers 3

2

"boilerplate code" is standard, reusable code fragments that are used again and again in projects, and are not particularly meant to be refactored out.

An example:

perl

#!/usr/bin/perl
use warnings;
use strict;

to answer your question, looking at this use of "boilerplate code", I imagine google translate is probably right, and would suggest: código repetitivo

Another meaning the phrase is used to denote is when a well-known pattern is followed in the working of a problem, such that the libraries in handling the project, or the project itself, generates such code as needed.

Here are a couple of examples:

html html5boilerplate site which allows you to generate custom variants.

ruby or rails uses it's own term scaffolding and generates such code as needed in its MWC-based server-side designs.

Here I would suggest: Andamios —the only translation I can find on the wikipedia article for ruby's scaffolding was the french Échafaudage (programmation)

1
  • 1
    gracias por el enfoque orientado a la programación, era lo que estaba buscando. Commented Jan 23, 2016 at 0:11
6

This is a tough one to translate. Some options, not perfect:

  • Código predefinido
  • Código base
  • Código modelo
  • Código estándar

Maybe even

  • Fragmento de código
  • Código reutilizable
4
  • Me gusta "Código reutilizable" +1
    – DGaleano
    Commented Jan 22, 2016 at 13:18
  • 1
    +1, gracias por la respuesta, he aceptado la de @roberto tomas debido a que me ha dado varios ejemplos orientados al área de la informática. Commented Jan 23, 2016 at 0:12
  • 1
    Buena respuesta (+1) que muestra varias opciones. Sin embargo, por favor considera remover "código base" ya que es el término generalmente utilizado para traducir "base code", el código de una "clase base" ("base class") al que se puede llamar o sobre-escribir. Aquí hay un ejemplo de tal uso en inglés y en español.
    – Jorge
    Commented Jan 4, 2017 at 3:49
  • 1
    Las que mejor traducen "boilerplate code" y al mismo tiempo suenan naturales en español son, para mi, "código base" y "código modelo". "Código reutilizable" también encaja. Para mi, "código repetitivo" no traduce correctamente el concepto "boilerplate code".
    – naggety
    Commented Feb 4, 2021 at 14:52
3

The term used in Spanish would be "código de cajón", which translates to something akin to "boxed code", "code in a box" or "prepackaged code".

Effectively, "código de cajón" would be prefabricated code ("código prefabricado") which is "taken out of its box" to be used as-is.

Two good analogies of what "código de cajón" would represent to Spanish speakers would be:

  • "IKEA code" ("código listo para ensamblar/armar") which would allude to IKEA's ready-to-assemble furniture.
  • "Canned code" ("código enlatado") which would be prepackaged code ("código preempacado") that can be taken out of a can, ready to be used.

The phrase "de cajón" has the following connotations:

  • It has been previously packaged, prefabricated.
  • It lacks creativity and originality.
  • It is predictable and obvious.
  • It doesn't require a lot of effort.
  • It is obligatory and mandatory (Since it doesn't require effort nor creativity, there will be at least someone who will use it).

Which means that "de cajón" can also be applied to "boilerplate project" as "proyecto de cajón", indicating that it is a prefabricated project.

Since "boilerplate code" is defined as code (or sections of code) which has to be included in several places with little to no alteration, it can be seen how the analogy of "IKEA code" would work, since it would be code that needs little to no "assembly".

Additionally, "boilerplate code" has been previously translated as "código de cajón and also as "código prefabricado".

Finally, if you are looking to translate "code template" and "project template" you might want to consider to use "plantilla" for "template", resulting in "plantilla de código" and "plantilla de proyecto".


Please notice that "Repetitive code" ("código repetitivo") is slightly different from "Boilerplate code", to illustrate this let's take a look at this exchange during a code-review meeting:

  • One more thing: What is this method, what purpose does it meet?
  • That's just boilerplate code.
  • Oh alright, it looks good.

Now let's replace "boilerplate code" with "repetitive code":

  • One more thing: What is this method, what purpose does it meet?
  • That's just repetitive code.
  • Oh alright, it looks good.

The second exchange should strike you as odd, but if you can't put your finger on it, keep in mind the following:

In software development, "repetitive code" ("código repetitivo") is code that violates the DRY (don't repeat yourself) principle and, as such, it carries negative implications.

The first exchange is common during code reviews, code that looks out of place can be explained as "boilerplate code" which is used to setup or initialize third-party functionality.

The second exchange is uncommon because not only does the author of the code admits of violating the DRY principle, the reviewer does not bat an eye at such admission.

In other words: "boilerplate code" is code that must be repeated, while "repetitive code" (also known as "copy-paste code") is code that is unnecessarily repeated and is frowned upon.

With that in mind, you can see why translating "boilerplate code" as "código repetitivo" might be an unfortunate choice. If "código de cajón" does not convince you, you would be better off using one of the options presented by spiral, instead. Also, using "andamios", as proposed by roberto tomás would be a better choice than "código repetitivo".

Having said that, "reusable code" ("código reutilizable") has the opposite problem: It has a good connotation that perhaps does not apply to "boilerplate code".

While "boilerplate code" could be seen as "reusable code" (after all, it is code that you must repeat in different projects), developers have the goal of writing "reusable code" as opposed to writing "boilerplate code".

In short, "reusable code" is code you write in a library or a module in order to adhere to reusability principles, while "boilerplate code" would be the code you have to write to include such library (or module) and perform the call to the functionality provided by the "reusable code". From that perspective, "boilerplate code" is code that results from leveraging "reusable code".


One final note regarding the term "scaffolding": While "andamio" is acceptable, "scaffolding" is translated as "andamiaje". In education, the term "scaffolding" also exists, and its equivalent in Spanish is "andamiaje".

2
  • Yours is indeed a good and worked out answer. Just a note about the "de cajón" expression: in some countries, being something "de cajón" means "ser evidente u obvio, estar fuera de toda duda o discusión". Example: "la respuesta a esa pregunta es de cajón". When you say "código de cajón" it sounds to me as obvious code, code that you had no doubt to write.
    – Charlie
    Commented Dec 23, 2016 at 7:53
  • 1
    @CarlosAlejo Thank you for your kind assessment, Carlos. As you mention, one of the meanings for "de cajón" is to be obvious, which is the third connotation that I listed. While "boilerplate code" is code that could be seen as obvious to some, there are developers that use it just because it needs to be used by anyone who seeks to leverage certain functionality, it's similar to when people repeat "frases de cajón" while they might not know their meaning, they know that are typically used to describe or respond to a certain situation.
    – Jorge
    Commented Dec 23, 2016 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.