I tested two approaches to store session data:
- The classic: 1 key, 1 object (And every key as
static final Stringin a class)
"user" --> UserObject
"preferences" --> List
- An approach with only 1 object
"sessionObject" --> SessionObject
UserObject and the list of preferences as attributes. This is a fairly simple example but imagine it with 20+ attributes.
The advantage I see in the second approach is that :
- You only have to delete one key to ensure session is empty
- You don't have to create the bothersome set of
final static Stringto create the keys
- You'll know what type of object to retrieve (Using key you have to
Do you see any problem I might went over? Or does anything go against best practices?