Custom backend state management question. I think this is a little subjective but I do want an objective side to this such as, why coud this be bad, or good and can this be simpler and better than any other state management option such as riverpod, at least for a small part of my backend.
I'm designing a state management for my backend and want to avoid the verboseness of Providers and the instantiations also. My front end code utilizes Riverpod beautifully, this is not a question referring to front end.
How does this state management look for backend code? Will I encounter any kinds of issues?:
void main() {
// Set name
DatabaseRepository.createName('John');
print(State.getName());
// Update database & state, name
DatabaseRepository.createName('Terry');
print(State.getName());
}
abstract class State {
static String? _name;
static void getNameFromDatabase(String name) {
_name = name;
}
static String getName() => _name!;
}
abstract class DatabaseRepository {
static String? _name;
static void createName(String name) {
_name = name;
State.getNameFromDatabase(_name!);
}
}