Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "string-free coding" a common term?

Recently i get in touch with Empire-db. The project doc. stated that they are using "string-free coding", intended to use less constant strings as possible to avoid typos and use the force of the compiler.

I was always a big fan of this principle, because i think as Java is a formal language it could be expresive for configuration like properties or xml and gives extra value by checking thru the compiler. Maybe at runtime there are less posibilities to changes without recompiling but this depends on each case.

Do you now more references or readings about this term/principle/design pattern ?

like image 951
PeterMmm Avatar asked Sep 29 '09 08:09

PeterMmm


3 Answers

This is the same thing as magic number vs constants. Using constants raises maintainability and readability. Constants also encapsulate change: a change in constant value is automatically propagated and, as for string-free coding, a misspelled constant is a compile-time error.

like image 157
dfa Avatar answered Nov 05 '22 22:11

dfa


I know little about Java, but this idiom is famous in modern C++. For example, Xpressive is a regular expression library that allows the programmer to write regex in C++, and does compile-time checking. Spirit is another example, where you could write EBNF in C++, and the compiler can check the syntax for you also :)

I think the term you are looking for is Embedded Domain Specific Languages.

like image 39
Khaled Alshaya Avatar answered Nov 05 '22 21:11

Khaled Alshaya


Never heard the particular expression, but Effective Java recommends to "avoid strings where other types are more appropriate" (Item 50).

like image 1
Fabian Steeg Avatar answered Nov 05 '22 21:11

Fabian Steeg