Reputation: 79
I'm programming an add-in for autocad, but I'm stuck with a design problem. I think it can be solved by a design pattern.
I'm trying to draw a table, the table have 2 parts a frame and a top/surface. so I have these 3 classes:
My problem is that if the length value given by the user is larger than max, than I have to produce 2 or more surfaces. the surface class also have to know which surface is the first and last. and the Draw class should also know where the first one ends to place the second surface.
What I have done now is I put the a method called calcNumberOfSurface(int len) into the Draw class and within this method I iterate through the number of surfaces to create each time a new instate of the class Surface. this solution have two problems also, the Surface class don't know if it the first or last. and can't define the end position of the first Surface. I have to implement this into the Draw class.
Is there any best practices or a design pattern to use that solve this problem?
Upvotes: 5
Views: 854
Reputation: 1973
I agree with Preston. Before you get to Design Patterns here I think you will have to first think about all the classes that are required and what members each class will have. For your example:
List<Surface>
(list of surfaces). This class will contain first and last Surfaces.Upvotes: 4