Which design pattern to choose
-
So I have ended up in a situation with a project I'm part of that has two types of lists (at the moment, at least): booking and shift list. Both lists are made so that we have a List object containing logic for both of them, and a separate Shift and Booking list objects for individual features. The List object is starting to be overwhelming. It has pagination, editor capabilities, selection and double click to open popups, mouse hover popups as well as filtering and paging. I would like to refactor the code to something more maintenable and perhaps into smaller units I suppose. What design patterns should I be thinking about here? If it matters, the List object contains over 3k lines of OO JavaScript code.
-
Answer:
Well in fact it is overwhelming. There is no simple answer or chosen design patterns. I will begin to apply the "http://en.wikipedia.org/wiki/Separation_of_concerns" design principle. One class/set of functions only do one thing. That will help to reduce the complexity. Then you can apply http://en.wikipedia.org/wiki/Structural_pattern. To begin, you can just use delegation. In your case the http://en.wikipedia.org/wiki/Decorator_pattern can fit as you can "decorate" the basic list with functionalities depending of the usage ... Before thinking DP, think separation of concern to divide your code in small understandable parts. Then use some DP to link them all. Good luck ! my2c
Tower at Stack Overflow Visit the source
Related Q & A:
- What's a good design pattern for bidirectional signals/events?Best solution by Programmers
- Which girl should I choose?Best solution by Yahoo! Answers
- Which one should I choose genetic engineering or chemical engineering?Best solution by Yahoo! Answers
- Which pattern should I get?Best solution by Yahoo! Answers
- How do you license an art design or pattern?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.