Re: Good idea or bad idea?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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

"pigeonrandle" <pigeonrandle@xxxxxxxxxxx> wrote in message
news:1169484481.039630.164240@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.


.



Relevant Pages

  • Re: Good idea or bad idea?
    ... 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 ... want to use a treeview to display it to the user. ... is mixing the 'data' with the UI a good idea? ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Crystal Reports
    ... > I am using the included version with .NET but when I print out a report there ... > is a tag line at the bottom indicating a demo version. ... * Have you entered your "permanent" registration key from Business Objects ...
    (microsoft.public.vsnet.general)