Hi,
My application creates a project that is structured like a tree, so i
want to use a treeview to display it to the user.
Would it be a good idea to create the various parts of project as
classes inherited from TreeNode and then just add them to the treeview
(ie adding extra properties to the inherited classes to hold my data)?
This would make outputting the project as an xml file very simple as i
could just traverse the treeview and get the nodes to write their part
of the document.
Or is it a better idea to create separate classes to hold my data, and
place them in the .Tag of a normal treenode?
Or is their another way i should do this?
Basically, is mixing the 'data' with the UI a good idea? I thought i
read somewhere that it is a bad idea :(.
Cheers,
James. 2 1429
The fact that you're asking this question shows that your subconscious is
trying to tell you that mixing UI and data classes is almost always a bad
idea. Generally one makes the data classes (business object classes)
independent of any particular type of user interface, because it gives one
the most flexibility in creating interfaces to the business objects - some
of which might not even be interactive user interfaces.
So plunking the object into the Tag property of a TreeNode isn't a bad idea,
or if you have a collection of those business objects at hand you might just
store in the Tag a value that you could use as a lookup into the collection
(an ID or other unique key). But "storing the object" in the Tag isn't
expensive anyway, since you're actually just storing a reference to the
object, which is probably just a four- or eight-byte value depending on
whether you're on a 32-bit or 64-bit operating system.
Tom Dacon
Dacon Software Consulting
"pigeonrand le" <pi**********@h otmail.comwrote in message
news:11******** **************@ l53g2000cwa.goo glegroups.com.. .
Hi,
My application creates a project that is structured like a tree, so i
want to use a treeview to display it to the user.
Would it be a good idea to create the various parts of project as
classes inherited from TreeNode and then just add them to the treeview
(ie adding extra properties to the inherited classes to hold my data)?
This would make outputting the project as an xml file very simple as i
could just traverse the treeview and get the nodes to write their part
of the document.
Or is it a better idea to create separate classes to hold my data, and
place them in the .Tag of a normal treenode?
Or is their another way i should do this?
Basically, is mixing the 'data' with the UI a good idea? I thought i
read somewhere that it is a bad idea :(.
Cheers,
James.
Tom,
Cheers for your thoughts. I have already started rewriting what i had
'done' and was looking for somebody to slap me on the back and say
'shrewd move' :o).
Thanks again,
James.
Tom Dacon wrote:
The fact that you're asking this question shows that your subconscious is
trying to tell you that mixing UI and data classes is almost always a bad
idea. Generally one makes the data classes (business object classes)
independent of any particular type of user interface, because it gives one
the most flexibility in creating interfaces to the business objects - some
of which might not even be interactive user interfaces.
So plunking the object into the Tag property of a TreeNode isn't a bad idea,
or if you have a collection of those business objects at hand you might just
store in the Tag a value that you could use as a lookup into the collection
(an ID or other unique key). But "storing the object" in the Tag isn't
expensive anyway, since you're actually just storing a reference to the
object, which is probably just a four- or eight-byte value depending on
whether you're on a 32-bit or 64-bit operating system.
Tom Dacon
Dacon Software Consulting
"pigeonrand le" <pi**********@h otmail.comwrote in message
news:11******** **************@ l53g2000cwa.goo glegroups.com.. .
Hi,
My application creates a project that is structured like a tree, so i
want to use a treeview to display it to the user.
Would it be a good idea to create the various parts of project as
classes inherited from TreeNode and then just add them to the treeview
(ie adding extra properties to the inherited classes to hold my data)?
This would make outputting the project as an xml file very simple as i
could just traverse the treeview and get the nodes to write their part
of the document.
Or is it a better idea to create separate classes to hold my data, and
place them in the .Tag of a normal treenode?
Or is their another way i should do this?
Basically, is mixing the 'data' with the UI a good idea? I thought i
read somewhere that it is a bad idea :(.
Cheers,
James.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: matty |
last post by:
Go away for a few days and you miss it all... A few opinions...
Programming is a craft more than an art (software engineering, not
black magic) and as such, is about writing code that works, first
and foremost. If it works well, even better. The same goes for
ease of maintenance, memory footprint, speed, etc, etc. Most of the
time, people are writing code for a use in the *real world*, and
not just as an academic exercise.
Look at...
|
by: Generic Usenet Account |
last post by:
I am going through some legacy code that has an "isNull()" method
defined on certain classes. I can see that this can be a good way to
eliminate certain types of crashes, by making this the first call in a
method (and bailing out immediately if it is true). However, if this
is such a good idea, why is it not common industry practice?
Mohan
|
by: dreamcatcher |
last post by:
I always have this idea that typedef a data type especially a structure
is very convenient in coding, but my teacher insisted that I should use
the full struct declaration and no further explanations, so I wonder is
there any good using typedef ? and I also know that when a data type
being typedefed become an abstract data type, so what exactly is an
abstract data type, is it any good ?
--
Posted via http://dbforums.com
|
by: Sensei |
last post by:
Hi!
I'm thinking about a good programming style, pros and cons of some
topics. Of course, this has nothing to do with indentation... Students
are now java-dependent (too bad) and I need some serious motivations
for many issues... I hope you can help me :) I begin with the two major
for now, others will come for sure!
- function variables: they're used to java, so no pointers. Personally
I'd use always pointers, but why could be better...
|
by: tony |
last post by:
If you have any PHP scripts which will not work in the current releases
due to breaks in backwards compatibility then take a look at
http://www.tonymarston.net/php-mysql/bc-is-everything.html and see if
you agree with my opinion or not.
Tony Marston
http://www.tonymarston.net
| |
by: sam.s.kong |
last post by:
Hi!
I've been programming ASP for 5 years and am now learning PHP.
In ASP, you can use GetRows function which returns 2 by 2 array of
Recordset.
Actually, it's a recommended way in ASP when you access DB as it
disconnects the DB earlier.
Also, it's handy as you can directly access any data in the array
without looping.
|
by: Charles D Hixson |
last post by:
I was reading through old messages in the list and came up against an
idea that I thought might be of some value:
"Wouldn't it be a good idea if one could "rewind" an iterator?"
Not stated in precisely those terms, perhaps, but that's the way I read it.
I appreciate that one could use a sequence rather than an iterator, and
that I don't understand the implementation issues. (They don't look
large, but what to I know?)
But would it be...
|
by: elgiei |
last post by:
Good morning at all,
i have to implement a server,that every n-seconds (eg. 10sec) sends to
other clients,which files and directory has been deleted or modified.
i build a n-tree, for each files on harddisk there's a node into n-
tree,
this solution is not good for large hard disk..
and i can't use inotify (it's forbidden),
and only c solutions are accepted
without third party software or external calls.
|
by: mike3 |
last post by:
Hi.
Is this a good idea?:
<begin code>
/* Addition operator: += */
const BigFix &BigFix::operator+=(const BigFix &rhs)
{
ErrorType err;
int lhs_sign = sign, rhs_sign = rhs.sign;
|
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: 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: 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: 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: 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...
| |