Hi
I have a basic qus. I am writing a middle-tier component. I have constructor
which takes 3 inputs, here's how it looks
internal ClassName(Database dbToUse, Int64 pk,DateTime Date)
{
}
Now , i want to know should I validate all the inputs before i start using
them, and if so in case of an invalid error whats the best way to report
error. Here on invalid input if I dont initialize the object and return, it
would return a object without any valid fields / memebrs.
Whats th general practice for these type of implementations. Is it feasible
to throw an exception?
-Sourabh 5 2433
Throw the exception and catch it outside of the object.
-benny
sourabh wrote: Hi I have a basic qus. I am writing a middle-tier component. I have constructor which takes 3 inputs, here's how it looks internal ClassName(Database dbToUse, Int64 pk,DateTime Date)
{
}
Now , i want to know should I validate all the inputs before i start using them, and if so in case of an invalid error whats the best way to report error. Here on invalid input if I dont initialize the object and return, it would return a object without any valid fields / memebrs.
Whats th general practice for these type of implementations. Is it feasible to throw an exception? -Sourabh
If the parameters were not what you expected them to be, throw an exception.
Yes, you should validate the parameters, unless you really know that they
will always be what you expect them to be.
--
Regards,
Kristofer Gafvert - IIS MVP http://www.ilopia.com - When you need help!
"sourabh" <so************@induslogic.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl... Hi I have a basic qus. I am writing a middle-tier component. I have
constructor which takes 3 inputs, here's how it looks internal ClassName(Database dbToUse, Int64 pk,DateTime Date)
{
}
Now , i want to know should I validate all the inputs before i start using them, and if so in case of an invalid error whats the best way to report error. Here on invalid input if I dont initialize the object and return,
it would return a object without any valid fields / memebrs.
Whats th general practice for these type of implementations. Is it
feasible to throw an exception? -Sourabh
Thanks
"Kristofer Gafvert" <kg******@NEWSilopia.com> wrote in message
news:ei****************@TK2MSFTNGP10.phx.gbl... If the parameters were not what you expected them to be, throw an
exception. Yes, you should validate the parameters, unless you really know that they will always be what you expect them to be.
-- Regards, Kristofer Gafvert - IIS MVP http://www.ilopia.com - When you need help!
"sourabh" <so************@induslogic.com> wrote in message news:eG**************@TK2MSFTNGP10.phx.gbl... Hi I have a basic qus. I am writing a middle-tier component. I have constructor which takes 3 inputs, here's how it looks internal ClassName(Database dbToUse, Int64 pk,DateTime Date)
{
}
Now , i want to know should I validate all the inputs before i start
using them, and if so in case of an invalid error whats the best way to report error. Here on invalid input if I dont initialize the object and return, it would return a object without any valid fields / memebrs.
Whats th general practice for these type of implementations. Is it feasible to throw an exception? -Sourabh
I think that if you are developing with a layered architecture, it's always best to do validation when data is collected. my middle tier typically assumes that data would be valid coming in. however, you definitely should but in debug or trace assertions to test the validity of data, so if a problem occurs, you can quickly pinpoint where the problem is
----- sourabh wrote: ----
H
I have a basic qus. I am writing a middle-tier component. I have constructo
which takes 3 inputs, here's how it look
internal ClassName(Database dbToUse, Int64 pk,DateTime Date
Now , i want to know should I validate all the inputs before i start usin
them, and if so in case of an invalid error whats the best way to repor
error. Here on invalid input if I dont initialize the object and return, i
would return a object without any valid fields / memebrs
Whats th general practice for these type of implementations. Is it feasibl
to throw an exception
-Sourab
When validating parameters of this kind the convention is to use.
either:
ArgumentException
ArgumentNullException
or
ArgumentOutOfRangeException
"sourabh" <so************@induslogic.com> wrote in message
news:eG**************@TK2MSFTNGP10.phx.gbl... Hi I have a basic qus. I am writing a middle-tier component. I have
constructor which takes 3 inputs, here's how it looks internal ClassName(Database dbToUse, Int64 pk,DateTime Date)
{
}
Now , i want to know should I validate all the inputs before i start using them, and if so in case of an invalid error whats the best way to report error. Here on invalid input if I dont initialize the object and return,
it would return a object without any valid fields / memebrs.
Whats th general practice for these type of implementations. Is it
feasible to throw an exception? -Sourabh
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: The Plankmeister |
last post by:
Hi...
What's the best method of validating input characters? I would like to
prevent users submitting exotic characters (such as those acquired on
Windows Systems by pressing ALT+) and thought...
|
by: Mark |
last post by:
Hi,
Im trying to validate a form, all the validating works apart from one field.
This particular field must consist of the first 2 characters as letters, &
the following 5 as numbers. And if it...
|
by: Terje |
last post by:
Hello I have a function like this
function checkquantitiy(quantitiy){
if(quantitiy.value != parseInt(quantitiy.value)) {
alert(quantitiy.value+" sorry not integer quantitiy");
}
} ...
|
by: bremdevnet |
last post by:
I have a ASPX page that loads a custom control. This first custom
control is made up of 2 textboxes and a Submit button. The user enters
data into the form, presses the Submit button and the ASPX...
|
by: chuck |
last post by:
I need some help with validating user input. I am writing a C computer
program for an intro to C course. Here is the situation. I am
creating an application that will do currency conversions. ...
| |
by: A TO Consultant |
last post by:
Hi All,
I am working on a web application that uses both asp classic and asp.net
pages. We need to validate user input to avoid attacks like sql injection.
Can a component be created that both...
|
by: robert maas, see http://tinyurl.com/uh3t |
last post by:
I'm working on examples of programming in several languages, all
(except PHP) running under CGI so that I can show both the source
files and the actually running of the examples online. The first...
|
by: satyabhaskar |
last post by:
hi all,
In my web page i have created radio buttons dynamically on to the page .....following is my code
string Course, Semester, Section;
int rowsCount;
string con =...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |