c pound

I reject your reality and substitute my own!
posts - 46, comments - 37, trackbacks - 40

My Links

News

Archives

Image Galleries

Blog Communities

Blog is a stupid word

Lunch Hour

Resources

Just stopping by

You don’t need to read my rant… this isn’t the blog you are looking for… move along.

Is it sane to rant about my own stupid design decisions? *shrug* So, I’ve got this pet side project that I’ve been slowly working on. One facet of the design is deciding how to display a specific set of objects to the user. (Note: This should not have been a hard decision at the time… read on.) In the first design, which I did way back in college, I gave the objects each a “Draw” function. The idea was that you would iterate over your collection of objects, call Draw on each one, and pass in a System.Drawing.Graphics object for the object to draw itself on. This was very simple and it worked very well. It was, however, a Bad Idea. I should have taken a look at simpler data structures and taken a moment to consider their simplicity. Take, for example, a string. It has no display functionality at all. It knows how to alter itself through functions like “Replace” and “Remove” but to actually show it to a user, you must use a Label or some other external display mechanism. The string is versatile, my object was not.

I recently came to this same decision, how to display my objects, in my project re-design. Obviously, I’m going to try to avoid previously implemented Bad Ideas. So, how do I go about displaying these things I need the user to see? My first thought was just to write a custom control and be done with it. However, part of my project is a plug-in system. So now I am considering other possibilities. I would like to be able to allow a savvy user to drop in a new piece of display code – a “Draw” function, if you will – to alter how these objects are displayed without having to replace the entire control that displays them.

Ok, I told you all of that so I could tell you this. One of the things I’ve come across since I started thinking about this yesterday is the Visitor pattern. Even if I don’t use this pattern for drawing purposes (I probably won’t, in fact), I’ll probably use it for something else in my project. I’ll let y’all know how it turns out.

Links
I use the Visitor pattern all the time (via Jeremy Miller's post)
and, of course, data & object factory - visitor pattern

Print | posted on Wednesday, September 28, 2005 5:32 AM |

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: