This discussion is archived
2 Replies Latest reply: Dec 29, 2010 9:02 AM by 827328 RSS

Help: Should I use Abstract Factory or Builder Pattern?

827328 Newbie
Currently Being Moderated
Hello,

Could any expert here please give some guideline? I am planning to implement something and considering using either Abstract Factory or Builder pattern based on what I read about both. However, I am unable to determine which one would be best used in this situation. Here is what I have -

1. I have a Object "MyObject" that contains some fields.
2. I need to use helper class/classes to set another "CallObject" based on fields in "MyObject". This helper class(es) reads values from "MyObject" and further compute it and set fields in "CallObject".
3. This "CallObjects" gets passed to external sdk method, which performs certain operation and returns "ResponseCallObject".
4. This "ResponseCallObject" then needs to be converted into "ResponseMyObject". Here I have to use again helper class(es) to read "ResponseCallObject" and further computer it and then set fields in "ResponseMyObject"

For steps 2 and 4, I would have to execute multiple methods in helper class(es) to set object correctly.

I hope I was able to explain the problem properly above. Based on what I read, I believe Abstract Factory or Builder Pattern would be a good choice to implement. But I am not sure which one would be the best solution as it seems when multiple steps are required to "build" object, the builder pattern would be good to use.

I need help on two things from anyone generous enough to help here :-)

1.) Is Builder pattern best to implement here?
2.) If I have to use either Builder Pattern (or Abstract Factory), could someone provide a hint on how my class structure would look like. (i.e. what goes in Director, Builder, Product etc.)

I will appreciate if anyone can throw some light on it.

Thanks!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points