I'm sure this has been asked but after searching the Internet, I just can
find a clear answer. When should you add a component versus a class to you
Windows Forms application?
The timer is a good example. I'm planning to add a customer system.timer to
run that should be accessible from several forms so I don't want to use the
forms timer. Should I add this to a new class or new component?
Thanks,
John 8 1270
* "John Granade" <jo**@granade.n et> scripsit: I'm sure this has been asked but after searching the Internet, I just can find a clear answer. When should you add a component versus a class to you Windows Forms application?
The timer is a good example. I'm planning to add a customer system.timer to run that should be accessible from several forms so I don't want to use the forms timer. Should I add this to a new class or new component?
Class.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Hi John,
I would not write a timer in a seperate class.
It is totaly complete, there is nothing reusable by setting it in a seperate
class, why would you seperate it. (There are people who transporting there
car with a truck but most don't)
But would you make your own clock and you want to put that on more pages,
than that clock would hold a timer itself of course to let the indicator go
smooth and not eat up completly your system.
Just my 2 eurocents.
Cor I'm sure this has been asked but after searching the Internet, I just can find a clear answer. When should you add a component versus a class to
you Windows Forms application?
The timer is a good example. I'm planning to add a customer system.timer
to run that should be accessible from several forms so I don't want to use
the forms timer. Should I add this to a new class or new component?
"Cor" <no*@non.com> wrote... I would not write a timer in a seperate class.
It is totaly complete, there is nothing reusable by setting it in a
seperate class, why would you seperate it. (There are people who transporting there car with a truck but most don't)
Oops... keep in mind that reusability isn't the only goal. People transport
their car by "ship" all the time by the way, it's hard to drive a car made
in the UK, Germany or Italy to the US.
By encapsulating a generic timer within a specific timer class the behaviors
are guaranteed to be consistent across the application. ATimer.Reset()
would (regardless of who called it (or from where)) always reset ATimer to
the proper setting. If every routine can reset it a common timer to any
value it wants one of them will surely get it wrong.
Tom
Hi Tom,
I have thought about such a thing, but doing that I thought also if it is in
a project good if from everywhere a timer can be reseted.
But maybe there are circumstances and than I agree.
But I was knowing while writing this I was on slippery ground.
:-))
Cor By encapsulating a generic timer within a specific timer class the
behaviors are guaranteed to be consistent across the application. ATimer.Reset() would (regardless of who called it (or from where)) always reset ATimer to the proper setting. If every routine can reset it a common timer to any value it wants one of them will surely get it wrong.
Hi Tom,
Maybe it is in the USA more normal, but I once was on a camping place in
Spain, and there was someone who had a campingcar in which he was
tranporting his car.
You know the distances in Europe, I found it funny to see.
Cor
Cor,
* "Cor" <no*@non.com> scripsit: I would not write a timer in a seperate class.
It is totaly complete, there is nothing reusable by setting it in a seperate class, why would you seperate it. (There are people who transporting there car with a truck but most don't)
I am still not sure if the OP wants to /write/ a timer or if he wants to
/use/ an existing timer class.
Just my 2 Euro cents...
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Hi Cor:
I'm not into "good or bad" :-) I think the guy said he needed it to be
accessible from many places. Despite that however it can be useful to
customize a timer class rather than remember to set a lot of common settings
every time you want one to be configured a particular way.
It's not entirely unlike a method that returns a connection string for
ADO.Net. One can always hardcode the string at the place it is used but
there is no advantage to doing that right? It makes it hard to change and
one of them will get messed up.
So if he needs a timer configured a standard way (even if it isn't accessed
globally) why not just ask for one preconfigured?
Tom
"Cor" <no*@non.com> wrote in message
news:eK******** ******@tk2msftn gp13.phx.gbl... Hi Tom,
I have thought about such a thing, but doing that I thought also if it is
in a project good if from everywhere a timer can be reseted.
But maybe there are circumstances and than I agree.
But I was knowing while writing this I was on slippery ground.
:-))
Cor
By encapsulating a generic timer within a specific timer class the behaviors are guaranteed to be consistent across the application. ATimer.Reset() would (regardless of who called it (or from where)) always reset ATimer
to the proper setting. If every routine can reset it a common timer to any value it wants one of them will surely get it wrong.
John,
The timer example aside.
I create a new Component when I want either a Visual Designer to help build
the class (by dragging & dropping other components onto it) or I want to
drag & drop this new Component onto another Visual Designer (such as another
Component or Form). Otherwise I create a Class.
I don't think I would create a new Component, just to drag a single
Component (System.Timer) onto it, unless that Component was easier to
configure from a Visual Designer then straight code.
Remember that Component is a Class that inherits from
System.Componen tModel.Componen t (more importantly they implement the
IComponent interface). The biggest benefit I see with Components is the
visual designer support in VS.NET.
Hope this helps
Jay
"John Granade" <jo**@granade.n et> wrote in message
news:O8******** ******@TK2MSFTN GP10.phx.gbl... I'm sure this has been asked but after searching the Internet, I just can find a clear answer. When should you add a component versus a class to
you Windows Forms application?
The timer is a good example. I'm planning to add a customer system.timer
to run that should be accessible from several forms so I don't want to use
the forms timer. Should I add this to a new class or new component?
Thanks,
John
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martyn Lawson |
last post by:
Hi,
I am currently working as an Analyst on a .NET Web Project using ASP.NET and
C#.NET.
I have a couple of, at least what should be, quick questions:
1. My understanding of UML says that the Controller classe of a Sequence
Diagram should be implemented as a private class within a component.
However, my Programmer has said that since the ASP code lives outside the
|
by: David Williams |
last post by:
I have a simple XML file that I have been using:
<component name="test">
<class name="class"/>
<component>
Up till now, the Xpath of "//component/class"
worked well to select the <class> tag.
Recently we added a namespace to the <component> tag:
|
by: Andrew Robinson |
last post by:
I need to create a shared static field for use within a number of different
classes. Which one should I be using or are they all really the same thing?
public class Widget
{
private Widget() {}
public static string DataField = string.Empty;
}
versus
|
by: David |
last post by:
Hello
I have made a component (MyWebForm) that inherits Page. This component
have a method called 'ComponentAdded' that shows a msgbox if it is in
design mode:
Public Class MyWebForm
Inherits System.Web.UI.Page
Public Sub ComponentAdded()
If ((Not Me.Site Is Nothing) AndAlso (Me.Site.DesignMode)) Then
|
by: Jordan Bowness |
last post by:
I make a similar post in another newsgroup, but this example is
simplified somewhat.
I have a component (cmpMyComponent) with 2 properties. The 1st property
is a string value (Description) and the 2nd property is a strongly typed
collection class (myCollectionProperty).
The collection contains a simple class (myCustomClass) which has 1 text
property (TextProperty).
| |
by: Don |
last post by:
Is there any way to detect when an item has been added to the Items
collection of a combobox or listbox? I am inheriting a Combobox and want to
validate items before they are added to the combobox, but I can't find
anything that will let me do that.
- Don
|
by: Edward Diener No Spam |
last post by:
The definition of a component model I use below is a class which allows
properties, methods, and events in a structured way which can be
recognized, usually through some form of introspection outside of that
class. This structured way allows visual tools to host components, and
allows programmers to build applications and libraries visually in a RAD
environment.
The Java language has JavaBeans as its component model which allows Java...
|
by: Joe |
last post by:
Is it possible to have a component which is global to the entire
application? I need to have a single component act sort of like a server
which components in any of the forms can access.
For example if I drop a component on Form1 & Form2 and that component has a
property called Server, at design time I would like to be able to assign the
global component to the Server property.
I'm sure I'm asking for way too much...
|
by: gary.bernstein |
last post by:
Any idea why line 57 fails? http://rafb.net/p/86JdGg61.html
gs = MyShutdown<Component, T1, T2, T3>(this);
Errors:
shutdown1.cpp: In constructor `Component<T1, T2, T3>::Component(int)':
shutdown1.cpp:46: error: type/value mismatch at argument 1 in template
parameter list for `template<template<class T1, class T2, class T3>
class Calling_Comp
|
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: 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: 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: 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: 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.
| |