Input validation for method in separate class

Author Topic
K Z
Member

Joined: 10 Sep 2008
Country:
Posts: 1

Posted: 13 Nov 2008 19:27:27

Hi, I have an API that I will use to develop applications internally as well as send to customers so they can develop as well. In this API, I have a method (below, which I slimmed it down alot).

MY QUESTION: Is it possible to validate the timeoutSeconds input to be greater than 0? I can't validate the input on run time because this method gets called repeatedly and the user will be bombarded with messages/asserts/etc.
I want to validate this input at <b>compile time</b>.

public string GetMessageFromQueue(uint timeoutSeconds)
{
retString = "";
while (Q.count &lt;= 0 || timeoutElapsed) { }

if (Q.count &gt; 0) {
retString = Q.Dequeue();
}
return retString
}

Edited by - some1s69 on 13 Nov 2008 20:12:34

Edited by - some1s69 on 13 Nov 2008 20:12:44

Hi, I have an API that I will use to develop applications internally as well as send to customers so they can develop as well. In this API, I have a method (below, which I slimmed it down alot).

MY QUESTION: Is it possible to validate the timeoutSeconds input to be greater than 0? I can't validate the input on run time because this method gets called repeatedly and the user will be bombarded with messages/asserts/etc.
I want to validate this input at <b>compile time</b>.

public string GetMessageFromQueue(uint timeoutSeconds)
{
retString = "";
while (Q.count &lt;= 0 || timeoutElapsed) { }

if (Q.count &gt; 0) {
retString = Q.Dequeue();
}
return retString
}

Edited by - some1s69 on 13 Nov 2008 20:12:34

Edited by - some1s69 on 13 Nov 2008 20:12:44
Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency