mercredi 23 août 2017

Nesting Two Design Patterns Good Practice?

I've been working with design patterns for a while now. I just have a quick question: Is nesting up on design patterns is a good practice? or does it not matter based on the need of the hour depending on the complexity and size of the project.

Case Scenario

Suppose I have an app that fires up 30 odd RESTful APIs. Now, I am using Builder Design Pattern to generate the request URLs with all the parameters. Now I am wondering if I could write up a quick Factory Design Pattern do Generate my Requests as well?

Meaning

When I want to make a call suppose to GET coffee details, and POST a new Coffee. Now should my service interact with a Request Factory to generate the entire request (for all sorts of API calls including get, post etc... and for coffee, car etc...) and the request factory internally interacts with the coffeeURLBuilder to generate a URL. Considering the factory would really help in a POST query where the data needs to be sent in json.

I just feel, it'll over complicate things. Can anyone guide me towards a better approach or if this approach is good?


List of design patterns being used:

  1. MVVM: for my application level logic.
  2. Service Locator: to find the service responsible for the operation.
  3. Builder Pattern: to build Request URLs
  4. Factory Pattern: (thinking of using it.) to generate the request, and shall interact with the URL builder to create the request

Aucun commentaire:

Enregistrer un commentaire