Spring Boot in Action - Spring made easy!
Spring in Action - Build powerful applications!
Build Talking Apps for Alexa - Add voice to your applications!
I'm going to be a "small government" candidate. I'll be the government. Just me. No one else.
Craig Walls wrote:The best way to avoid anyone messing with the properties of a singleton bean like that is to (1) make them final and (2) not provide setter methods for them. Ideally, provide the values via constructor args and not by setters.
That said, I recognize there are cases where you need setter methods for non-final properties. In that case, it may be best to only inject those objects as an interface type that doesn't offer setter methods. Without those setter methods, it'd be difficult (not impossible) to change the values.
In the end, however, if members of the team are hell-bent on changing values that shouldn't be changed, the best way of dealing with it is with code review and frank discussion about why changing them is wrong. In short, although there are technical remedies, the real problem is a people problem, not a technical problem.
I'm going to be a "small government" candidate. I'll be the government. Just me. No one else.
Walter Andresen wrote:does it mean that the bean must tread safe?
Spring Boot in Action - Spring made easy!
Spring in Action - Build powerful applications!
Build Talking Apps for Alexa - Add voice to your applications!
Spring Boot in Action - Spring made easy!
Spring in Action - Build powerful applications!
Build Talking Apps for Alexa - Add voice to your applications!
I'm going to be a "small government" candidate. I'll be the government. Just me. No one else.
Spring Boot in Action - Spring made easy!
Spring in Action - Build powerful applications!
Build Talking Apps for Alexa - Add voice to your applications!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |