I have a question about design, performance, and code reusability. Which one of these would be the best as far as performance/speed
Send a textbox to a public class to check it and process/not process the text in it (which would be called from many different forms-would be reusable
-or
Validate it locally on each for
Would there be a major difference in performance/speed? Is there any way to actually see the differences in performance
Thanks
John 6 1327
On Mon, 16 Feb 2004 10:01:05 -0800, "John"
<jo***********@ crestoperations .com> wrote: Would there be a major difference in performance/speed? Is there any way to actually see the differences in performance?
I doubt it. When you send a textbox you're very likely talking about
passing a TextBox argument to a method on the same thread, correct?
That just passes an object reference on the stack which is almost
immeasurably fast. Now if you had to marshal to a different thread
(let alone a remote system) things might be different.
-- http://www.kynosarges.de
> Which one of these would be the best as far as performance/speed: Send a textbox to a public class to check it and process/not process the text in it (which would be called from many different forms-would be reusable) -or- Validate it locally on each form
Send textbox to a single validator/processor function.
The reason is that you would not be sending the textbox itself, just a
pointer to it.
The bigger questions is why are you considering sending a textbox and not
just the string of contents?
Would there be a major difference in performance/speed? Is there any way to actually see the differences in performance?
Nah, performance would be the same. At most you are sending a pointer.
--
gabriel
John,
I agree with the others that theres no significant performance
difference as yr only passing references when you pass the text box to a
function. Ideally you'd only have to send the the string to validate/
process or otherwise
Thanks
John wrote: I have a question about design, performance, and code reusability. Which one of these would be the best as far as performance/speed: Send a textbox to a public class to check it and process/not process the text in it (which would be called from many different forms-would be reusable) -or- Validate it locally on each form
Would there be a major difference in performance/speed? Is there any way to actually see the differences in performance?
Thanks, John
--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com
Thanks for the replies, Christoph and gabriel. The reason (I was
thinking) was that I wanted to clear the textbox and set the focus to it
without having to create an if statement in each textbox's click event.
Ex:
bool blnValid = csValidate(strT extBoxText.Text );
if (blnValid)
{
//valid
}
else
{
//invalid-clear and reset focus
}
as opposed to:
csValidate(txtT extBox)
A lot of these forms will be using the same validation comparisons based
on what type of textbox it is, and I wanted to share them all. Is that
a bad idea, or is there some other way that would be better? I'm
definitely open to suggestions. I'm having to rebuild a COBOL program,
and I'm open to anything (except building another COBOL program -
yuccckkk!).
Thanks,
John
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
John wrote: The reason (I was thinking) was that I wanted to clear the textbox and set the focus to it without having to create an if statement in each textbox's click event.
First of all, you can have all the textboxes use the same OnClick
handler. That's why on the designed the OnClick handler is a drop-down
text box. You can code one handler then for all the other controls
select the same function name.
You can see which textbox triggered the event via the "sender" argument.
Something like this:
private void my_custom_Click (object sender, System.EventArg s e) {
string senderName = ((TextBox)sende r).Name;
if (senerName == "TextBox1") {
// Process this.TextBox1
} else if (senderName == "TextBox2") {
// Process this.TextBox2
[..whatever..]
}
}
A lot of these forms will be using the same validation comparisons based on what type of textbox it is, and I wanted to share them all. Is that a bad idea, or is there some other way that would be better?
It's a good idea, in cases like this, doing it "the rioght way" will
save you tons of typing and maintenance.
--
gabriel
gabriel,
Thanks for the advice and the code snippet. I'll definitely use it. I
definitely want to save "tons of typing and maintentance."
John
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: middletree |
last post by:
Yesterday, I posted a problem which, by the way, I haven't been able to
solve yet. But in Aaron's reply, he questioned why I did several things the
way I did. My short answer is that I have a lot to learn, but now I'd like
to ask anyone who reads this, including Aaron, for some clarification. I
imagine others might benefit, too.
"Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote
> A few suggestions.
> (3) why do you constantly set...
|
by: Peter Foti |
last post by:
Simple question... which is better to use for defining font sizes and why?
px and em seem to be the leading candidates. I know what the general answer
is going to be, but I'm hoping to ultimately get some good real world
examples.
Fire away! :)
Regards,
Peter Foti
|
by: DrUg13 |
last post by:
In java, this seems so easy. You need a new object
Object test = new Object() gives me exactly what I want.
could someone please help me understand the different ways to do the
same thing in C++. I find my self sometimes, trying
Object app = Object();
Object *app = Object();
Object app = new Object();
|
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: |
last post by:
I have an app that retrieves data from an Access database. At the moment I
have the SQL string as a Const in my app. I understand this is not best
practice. I don't want the user to have access to read or modify this string
so I don't want to store it in an INI / Text file or in registery. Can
someone please tell me the best practice for this.
Thanks
Mike
|
by: Steve Peterson |
last post by:
Hello
In my projects I like to use the "Me." (Me"dot") keyword to refer to any
members or methods (ex: Me.MyVariable = "Bob" or calling a sub by Me.MySub)
in the particular class I'm working with. I also like to use the "MyBase"
keyword to refer to any members or methods in an inherited class in the same
way, if I'm working with that. For me, at least, using these keywords really
helps me clarify my code.
My question is really twofold:
|
by: =?Utf-8?B?bW9mbGFoZXJ0eQ==?= |
last post by:
In VB6, we created a number of ActiveX DLLs that all shared a similar
interface. The main application would load these in dynamically (late-bound.)
This worked well for our situation because we could update the DLLs
independently of the main EXE, and performance was not a problem.
We want to do the same thing in C# (at least test it), but we are not
exactly clear what the best practice is. We would prefer to do something
similar, but we...
|
by: samadams_2006 |
last post by:
Hello,
I'm interested in taking the following exam for an upcoming job.
Exam 70-315: Developing and Implementing Web Applications with
Microsoft Visual C#â„¢ .NET and Microsoft Visual Studio .NET.
Since the job is being offered soon I need to know the "quickest" and
"best" way to prepare for this exam. Are there any books, practice
exams, etc. that are considered "THE BEST"?
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: 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: 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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |