Better way of handling: Part -1
Better way of handling: Part -1
Some time back I was Doing troubleshooting for one my colleague. Came across code which could have written in better was
Sample Code which was earlier written
Problems with above code:
Change in value will fail the Logic. As Source is Hardcoded.
Change in Value will have to replicate in multiple places.
After some fine tune code changed as shown below
Benefits:
Change in Enum will auto affect all code. No change to be anywhere.
No Hardcoded String value to be checked.
Type Safety.
Comments
Post a Comment