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

Popular posts from this blog

Shared / Static Class in vb.net/C#

Xamarin Forms - Change Colour of Navigation Bar (Page Title For Master-Detail Template)

Xamarin Forms : PopUp Page with RG.Plugins.Popup