Convert hardcoded strings to an enum/constants.
We should convert hardcoded strings to an enum/constants. I.e. the stuff we pass into bundles & other such strings in our application.
We have a set of enums:
BundleKeys // for bundles.. etc...
Comments (5)
-
reporter -
reporter Basically the idea is less unexpected errors. If you misspell business here:
args.getParcelable("busienss")
it will throw a NPE somewhere down the line which may not be obvious as to the root cause. Whereas:args.getParcelable(BundleKeys.BUSIENSS)
will throw a compiler error. You'll know exactly where the problem is. -
reporter Hmm... we could achieve the same thing with string resources. :)
-
reporter Kind of messy though, since we go through the localization. Could create more gotchas.
Let's use constants instead for these keys.
-
reporter This has already been started. Let's do an investigation at some point and take care of this with the rest of the code.
- Log in to comment
I'll start this with my code. Let's adopt the new way & maybe later in a refactor convert the old code.