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 : PopUp Page with RG.Plugins.Popup

Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard)