String interning
If we examine a typical business application, we would frequently find that some string constants are used more than once in the source code. For example, we would probably find the ID, name, and similar strings all around the program.
This doesn't represent a big waste of memory. Compilers, however, sometimes look at that in a different manner and (correctly) notice that we don't really need multiple copies of such strings. Each (distinct) string constant can only be stored once in a complied program, and the code can then reference this shared data. By this, the compiler uses a flyweight design pattern to implement a concept called string interning.
We can find this behavior in various programming languages. It is, for ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access