Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
asgs112756yIt is a way to document magic strings (similar to magic numbers). If you decide to change that to something across your module or project (though it seldom happens), it is easier to do.
By the way, I'd prefer Constants.EMPTY_STRING -
@asgs yes it makes sense for a particular case..like an empty message for a particular case... But for everything.. i think its a waste of time...
-
Depending on the language, you save memory and garbage collector work because "" creates a new string.
Depending on the app, this can save tens of thousands of strings.
You'll get the best response from the guy if you just ask him why. -
willol13896y@ravijojila such a micro-optimisation, can't see a real-life situation where that would have any impact
Yeah, definitely ask your team lead. Worst case scenario, you'll learn something. My guess is that it's just to follow a general good practice of avoiding magic string, it's not strictly necessary for empty strings but might as well apply the same principle everywhere to prevent sloppiness
Related Rants
I dont know why but my team lead urges everyone to use empty string as a constant string variable from our utility class instead of just putting "" in our code... Its really cringe worthy... Why use Constants.NONE when you can put "" just to avoid null exception working with Strings..
rant
cringe worthy
android