I'm still somewhat new to "proper" design, but I'm trying to keep with it as much as possible. I thought I was OK but I've run across a slight dilemma: how should I be implementing the actual drawing and updating of entities?
For example, in my project I have a TextBox
class. The 'easy' way, and the way that I usually see in tutorials across the Internet, are to give this class its own Update()
and Draw()
methods. But I don't think my textbox class should have to know anything about how it's being drawn, so I thought it might be good to make it implement some kind of Drawable
interface, but even that still involves implementing drawing code.
So I thought of adding all my TextBox
es to a List<TextBox>
that a drawing class would load to handle the drawing, but then I realized that my TextBox
class itself doesn't (and shouldn't?) have a Draw()
method within the class, so I would have to write a sister method in the graphics implementation somewhere as a DrawTextBox()
or something like that. I guess this COULD work, but I can't shake the feeling that having to have this kind of coupling of classes is bad practice.
So where should I ultimately be placing the code to draw, and where should I have the logic behind it? A TextBox
, for example, involves drawing multiple elements, and it's timed because it's a typewriter-style output, and I eventually want to add in-text commands for delays and sound. Should I include some of this stuff in the main class? Have a Draw method in some graphics class somewhere else? And then later dealing with timing and sound, how should I be separating all of it?