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(Datab ase 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 2451
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(Datab ase 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******** ******@TK2MSFTN GP10.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(Datab ase 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******@NEWSi lopia.com> wrote in message
news:ei******** ********@TK2MSF TNGP10.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******** ******@TK2MSFTN GP10.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(Datab ase 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(Datab ase 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:
ArgumentExcepti on
ArgumentNullExc eption
or
ArgumentOutOfRa ngeException
"sourabh" <so************ @induslogic.com > wrote in message
news:eG******** ******@TK2MSFTN GP10.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(Datab ase 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
a way of doing this would be to compare the submitted strings with the array
keys returned by get_html_translation_table(HTML_ENTITIES), but padding this
array out with all the remaining normal keyboard characters.
But... am I reinventing the...
|
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 dosent meet these requirments an error
message will be displayed. I have pasted the code (and highlighted the
relevant parts) below in the hope that someone can help me out with this.
Ive been trying to suss it out all week & it's driving me nuts!...
|
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");
}
} //End of function
|
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 page should
either load a new custom control during the postback or (if validation
fails) reload the first custom control. I've attached some validation
controls without a problem but the client-side validation doesn't seem
to be working...even in...
|
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. The user
will be presented with a list of 5 selections they can make. They will
then be prompted for which selection they want to enter (which can only
be 1-5, no characters or anything like it). Once they select the
number, 1 for Euro, 2 for...
| |
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 page types can use? Is that the best
approach? Would I simply use pattern matching to validate strings and/or
remove any unwanted characters?
Thanks in advance.
|
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
set of examples, after decoding the HTML FORM contents, merely
verifies the text within a field to make sure it is a valid
representation of an integer, without any junk thrown in, i.e. it
must satisfy the regular expression: ^ *?+ *$
If the...
|
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 = ConfigurationManager.ConnectionStrings.ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
try
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 we have to send another system
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |