Separate presentational strings from logical keys

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the architecture category.

Last Updated: 2024-04-25

Presentational representations of data might be capitalized or long or in other languages like German.

At project start it might seem easier to refactor the key to its newly requested presentational form and spare yourself adding a layer. However this is rarely a good idea (as these are likely to change again and because your previous testing become invalid). What's more, the keys become uintuitive, esp to non-native speakers

e.g. in project A, I had difficult to remember code like

<?php
    if (backpack_user()->hasRole('AdministratorIn')) {
    }

It would have been much simpler to have:

<?php
    if (backpack_user()->hasRole('admin')) {
    }