A design pattern question -
I am preparing an application, and I am unable to pinpoint the correct design for it. I have one in mind, but it is not part of GOF pattern and therefore I'm not sure that this is a good way.
My project probably creates data from any data 15-20 documents (documents are of the same type, but data can vary widely). After receiving the data, it should be displayed and displayed in any supported 4 formats. Also, to complicate matters, even though the documents are broadly classified into 4-5 types, some documents (in these classifications) are formatted in the same form.
Now, I have given it the following methods:
- Data creation
- Data display
Data creation common interface Creates an interface with an interface that can control all of these documents.
The data display reads through the data object and displays the way it is needed.
My first question is - I did not know about such an interface object. GOF pattern set is such a good design decision?
As I mentioned earlier, only two documents are formatted in such a way - across classification. The problem here is that other documents - which should be formatted equally - are not. Therefore, when I receive the data, I want to clone the code in a scenario, which I do not want.
So, my second question is - What is the best way to handle it?
If someone can help me, I would be very grateful.
Do not try too hard patterns push in advance understand some designs And then try the manifest pattern in them. Patterns are for conversation and it can only be seen as reusable for some specific concern.
So your wide problem is that you have provided X documents and Y.
- Try creating a class hierarchy to create a document, Can cause some logic or use the interface
- If you can not detect the interface of all types of documents, you can trust the adapter ,
- For multiple renders, Take a look at the visitor pattern, decorator pattern or strategy pattern, or simply plain succession / polymorphism Is used with Y, which implements the same interface. It depends on the nature of variations
- To get the right renderer in terms of usage, you can use the factory to embed the decision and immediate logic .
GoF Patterns are less granularity than your problem. You have to find a design that corresponds to your very specific requirement. In case of suspicion, always choose the design that is simple / more intuitive .
My 2 cents
Comments
Post a Comment