Hi,
I'm trying to write a update method, in which when the user clicks the
update button the update method is passed 10 form fields. Then a update SQL
is run to update the database.
My question is whats the best way to pass large numbers of parameters into a
method. Ten seems a large number to be passing into and out of a method.
Stephen 4 4012
It depends what the data represents, but I see no problem with 10
parameters, *as long as* they are clearly named...
However, if the 10 fields represent properties of an entity (as is often the
case with form fields), I would create an object (class) to represent that
entity; the UI would simply read from the form fields, putting the values
into properties on the class; depending on layering (how far my object is
from the DB), I would then either call a Save() method on the object itself,
or call the Save() method on a DAL helper that accepts the (single) object
as a parameter.
Note that this allows the data to be fetched in the same consistent way, and
also allows for the UI to be data-bound directly to the entity class if
appropriate (so no read/write property code).
If I am mistaken, and this /doesn't/ relate to such closely related
properties of an object, then any reasonable approach shold work... again,
/as long as/ the API is clearly named. For example, if it saves a customer
and an order, have SaveCustomerAnd Order() (with the 10 strongly-typed,
clearly-named parameters).
Marc
"MicroMoth" <st***********@ forvus.co.uk> wrote in message
news:29******** *************** ***********@mic rosoft.com... Hi, I'm trying to write a update method, in which when the user clicks the update button the update method is passed 10 form fields. Then a update SQL is run to update the database. My question is whats the best way to pass large numbers of parameters into a method. Ten seems a large number to be passing into and out of a method.
Stephen
1) use parameters' array to send data to the function http://msdn2.microsoft.com/en-US/lib...db(VS.80).aspx
2) Create and send object that keeps all you params
I recomend first case
"MicroMoth" wrote: Hi, I'm trying to write a update method, in which when the user clicks the update button the update method is passed 10 form fields. Then a update SQL is run to update the database. My question is whats the best way to pass large numbers of parameters into a method. Ten seems a large number to be passing into and out of a method.
Stephen
--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
IMO, it depends what we are doing here; if the 10 is actually something like
(for example) a user-defined list of strings(variabl e-size, identically
typed) then I agree 100% : "params string[] someParam" would be a good
choice. However, if the successive parameters are, in fact, different
things, then "params object[] data" is the *last* thing I would want to do;
you'd then need to remember that data[0] is the name (a string), data[1] is
the age, etc; it provides no type-safety, no "is everything provided"
safety, and provides no clue to the caller what they should be providing
(types, how many, or what they mean). In this case, "string name, int age,
(+another 8)" is much more supportable long term, as it addresses all of
these.
To me, at least. Put it this way: if somebody in my team did that to me,
then they'd be re-doing it before it gets anywhere near a server...
Marc
"Michael Nemtsev" <Mi************ @discussions.mi crosoft.com> wrote in
message news:36******** *************** ***********@mic rosoft.com... 1) use parameters' array to send data to the function http://msdn2.microsoft.com/en-US/lib...db(VS.80).aspx 2) Create and send object that keeps all you params
I recomend first case
"MicroMoth" wrote:
Hi, I'm trying to write a update method, in which when the user clicks the update button the update method is passed 10 form fields. Then a update SQL is run to update the database. My question is whats the best way to pass large numbers of parameters into a method. Ten seems a large number to be passing into and out of a method.
Stephen
-- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche
Certainly it's really depends on. But trying to guess by origin message " is
passed 10 form fields" we treat with one type params :)
We even could create and send XML, that is self-described, as param
"Marc Gravell" wrote: IMO, it depends what we are doing here; if the 10 is actually something like (for example) a user-defined list of strings(variabl e-size, identically typed) then I agree 100% : "params string[] someParam" would be a good choice. However, if the successive parameters are, in fact, different things, then "params object[] data" is the *last* thing I would want to do; you'd then need to remember that data[0] is the name (a string), data[1] is the age, etc; it provides no type-safety, no "is everything provided" safety, and provides no clue to the caller what they should be providing (types, how many, or what they mean). In this case, "string name, int age, (+another 8)" is much more supportable long term, as it addresses all of these.
To me, at least. Put it this way: if somebody in my team did that to me, then they'd be re-doing it before it gets anywhere near a server...
Marc
"Michael Nemtsev" <Mi************ @discussions.mi crosoft.com> wrote in message news:36******** *************** ***********@mic rosoft.com... 1) use parameters' array to send data to the function http://msdn2.microsoft.com/en-US/lib...db(VS.80).aspx 2) Create and send object that keeps all you params
I recomend first case
"MicroMoth" wrote:
Hi, I'm trying to write a update method, in which when the user clicks the update button the update method is passed 10 form fields. Then a update SQL is run to update the database. My question is whats the best way to pass large numbers of parameters into a method. Ten seems a large number to be passing into and out of a method.
Stephen
-- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche
--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hursh |
last post by:
Hi,
I have written some stored procedures in SQL and these procedures
return some value.
I want these values to be captured by the ASP code.
I am able to access the tables using ADO( recordsets ) but is there a
way to pass data returned from stored procedures to vairables in ASP
code.
|
by: David |
last post by:
Hello.
I am looking for advice on what is "best practice" regarding looping
through a form to check its checkboxes and associated data fields.
Here is what I am trying to do (Here is the page I am working on:
http://www3.telus.net/thothworks/LinLeastSqPoly4.html).
I provide a form for a user to enter up to twenty (M = 20) data pairs.
The user need not enter data for all twenty pairs, but
the user must indicate that data is present by...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to use.
The above URL is version 1.0 (draft) that resulted. IMO, it is not a
replacement for the FAQ,...
|
by: Joe Bloggs |
last post by:
I have a general question on best practice regarding data access. I have
the code below, a static method defined in a class that I use in a data
layer dll. The method takes a string as its parameter, connects to the
database , executes the string (in this case SQL) in the form of a
SqlDataReader and then returns the SqlDataReader.
Here's the method...
public static SqlDataReader SQLServerExecuteSQL(string SQLstr)
{
|
by: Johnny |
last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form
(fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip
code. The user can enter a zip code in the text box and click a button to
determine whether the zip code is unique. If the zip code is not unique,
another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip
code is passed to the lookup form/dialog by reference. I then load a...
| |
by: Anonieko Ramos |
last post by:
ASP.NET Forms Authentication Best Practices
Dr. Dobb's Journal February 2004
Protecting user information is critical
By Douglas Reilly
Douglas is the author of Designing Microsoft ASP.NET Applications and
owner of Access Microsystems. Doug can be reached at
doug@accessmicrosystems.com.
--------------------------------------------------------------------------------
|
by: tshad |
last post by:
I need to pass a few parameters to my Windows Service program. The end user
will be changing the parameters and settings should be saved.
What is the best practice
- use app.config
- use .ini file
- use Registry
- write a Windows Application program and save the settings to database
table
|
by: csgraham74 |
last post by:
Hi guys,
Basically i have been developing in dotnet for a couple of years but
ive had a few issues in regards to error handling.
For example - I have a class that i call passing in a stored procedure
and connection string as a path. My method returns a dataset. In my SP
i have an output parameter which tells me whether the SP select is
successful or not. If i get a error code passed back then i throw an
exception this then returns...
|
by: Dave |
last post by:
I have multiple forms that will create an object. Basically a energy
efficiency measure object. The measure object will have a couple of
required properties set but after that it can have 10-20 different fields
that are optional per measure.
How do I account for the different fields that will be
posted from the different forms when I create the measure object? Should
I create a constructor method with just the required fields as the...
|
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: 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: 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: 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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 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...
| |