what is the advantage of using Class.getSimpleName()
, instead of hardcoding the class name in java?
Class.getSimpleName()
will always return you the name without any typos, while hardcoding the class name can lead to a typo.
If you change the class name, Class.getSimpleName()
will return the updated name, while the hardcoded one won't change.
When you re-factor your Class name later, the hardcoded name won't change and the getSimpleName()
always gives you the current Class name.
You always need to remember the places to change if you hard code the class name while updating the Class name.
Not only Class name, avoid hard coding AMAP. Otherwise it really increase the cost of maintenance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With