Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple return points - is it OK practice?
Message
From
01/02/2013 16:21:13
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01564936
Message ID:
01564963
Views:
52
Break it down into smaller methods. Each if and each else should be their own class. Study up on refactoring and design patterns.

>But how do you navigate in all this if else code
>
>E.g.
>
>Int32 SomeValue;
>
>If (!Int32.TryParse(SomeString, out SomeValue) || SomeValue = 0)
>   {
>   // First Error here
>   }
>   else
>      { more code that may cause problems
>             if ...
>                     
>      }
>}
>
>In other words, it is very hard to keep track of all these if else and {}
>
>BTW, I usually create several UnitTests per method - for invalid parameters, for some unreal values, etc.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform