Our (Java) project deals with multiple entities stored in a relational database. For example, we deal with persons. We have service methods (on singletons) which allow creation or modification of these entities. These accept at least 2 parameters:
- one for the state of the entity as requested in the HTTP POST being processed,
- and the other for its state before the POST, if it existed, or
null(undefined) if it doesn't exist yet
For example, if we had an updatePerson method, its prototype could be:
public void updatePerson(Person person, Person personDB) {
...
}
When the user fills a form and clicks Save, person corresponds to the object described by the form, while personDB is null if it's a creation, or what was in the database before the user clicked.
In other words, our parameter naming convention is entity vs entityDB, which I find understandable, but not great.
I would prefer that both names be more specific, for example personModified vs personExisting. Yet, I am not so keen on personModified since I don't want to give the reader the impression that the code is necessarily modifying (rather than creating). Are there standard naming conventions for this pattern, whether in Java or generic?
By the way, our project is actually in French (in case someone has a solution which doesn't work in English).
I see two ways: