Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multiple return points - is it OK practice?
Message
De
01/02/2013 16:21:13
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01564936
Message ID:
01564963
Vues:
50
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform