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:36:15
 
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:
01564968
Views:
44
This is what sample code reminds me of when compared to production code.

http://www.youtube.com/watch?v=bufTna0WArc



>The parameters are passed as XML string. This is the typical method and I am following the pattern which was developed before me:
>
>This is part of the code of the method I wrote today and unit testing right now
>
>
>internal static String GetGuestActivity(Dictionary<String, String> parameters)
>        {
>            Logging.Log(1, "Entering GetGuestActivity");
>
>            List<String> requiredParameters = new List<String>() { "tnGuestNo", "ttStartDate", "ttEndDate" };
>            //always required parameters (but not used)          { "tcSalesPoint", "tcOperator" };
>            //optional parameters                                { "tcFilter"};
>            
>            //TODO: get rid of not used tcFilter parameter in the code and SP
>
>            HashSet<String> availableReturnTypes = new HashSet<String>(StringComparer.OrdinalIgnoreCase) { "STR", "ADO", "XML", "XM2" };
>
>            String messageText = "";
>            Int32 errorValue = 0;
>            Int32 statusCode = 0;
>
>            // If all necessary parameters are present and valid, proceed...
>            if (Functions.CheckRequiredParameters(parameters, requiredParameters, availableReturnTypes, out statusCode, out messageText))
>            {
>                // Parse out the parameters
>                String tcGuestNo = Functions.GetParameterValue(parameters, "tnGuestNo");
>                String tcStartDate = Functions.GetParameterValue(parameters, "ttStartDate");
>                String tcEndDate = Functions.GetParameterValue(parameters, "ttEndDate");
>                String tcFilter = Functions.GetParameterValue(parameters, "tcFilter");
>
>                Decimal guestNo;
>
>                if (!Decimal.TryParse(tcGuestNo, out guestNo) || 0 == guestNo)
>                {
>                    statusCode = 999;
>                    messageText = "tnGuestNo expression can not be zero";
>                    return Base.LogAndReturnResult(errorValue, statusCode, messageText);
>                }
>
>UPDATE. I changed this method to use only 1 exit point as it has only 2 exit points, so it was relatively easy to convert.

bufTna0WArc
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform