Home  /  Questions  /  Question

55   94.7
Jan 10, 2012

What pattern(s) to use for this system ?


I had another look at Design Pattern Framework 3.0 which I own, but without really finding what I need.

Rectangle is a "higher-level" type than Drawable, a user shouldn't need to call its SetData(), it does it for you.
That brings the question whether Rectangle should "have a" Drawable against being one but,
I want the user to be able to create its own Drawable objects and it'll be less work for derived types.

Any ideas ?

Thank you.
public abstract class Drawable
        private VertexBuffer _buffer;

        public abstract void Render();

        public void SetData()
                // Upload data to buffer

public class Rectangle : Drawable
        public Rectangle()
                // Sending an array of 4 colored vertices
                var array = ...

        public int X;
        public int Y;
        public int Width:
        public Height;

        public override void Render()
                // Render the object with OpenGL


50   50
Jan 11, 2012
I have found a free online barcode generator to make my own barcodesfor products and it is really convenient and useful. KEEPAUTOMATION Free OnlineCode Reader I just want to share it with you, everybody, maybe you can try itsomeday you may have a try someday.

377   99.9
Jan 17, 2012
I didn't fully understand your question. But if your question whether Rectangle should "have a" Drawable then the answer will be yes. Drawable is low level and abstract. Like Shape which is low level abstraction of rectangle, triangle and others Drawable is also low level abstraction. 
Yes, user can create is own Drawable object
        Drawable rectangle = new Rectangle(); // Probably there is constructor params

SetData has no parameter in base but you are calling it with parameter from Rectangle. Seriously???
Please let me know the details what is confusing you and what do you want so that I can better help you.


55   94.7
Jan 18, 2012
I fixed it, thank you.