0

I have been asked to produce a basic Design Pattern for an online commerce system (Amazon, Play.com etc..) and I have chosen to concentrate on the Facade Pattern as I feel this is pattern is used mostly throughout the system. This is what I have so far:

System Operations:

  • Order Product

  • Stock/Availability (This checks the stock of the product)

  • Authentication (This checks to see if the user is signed in / registered)

  • Dispatch (Sends the product name / customers details to dispatch)

The suggested "Facade Pattern" will work by the user is only required to see/know order_product function and therefore the other components are "triggered" from this one action.

My question is, with this type of system, is this a good and right design pattern to use? Also, the operations, can anyone else think of any others that may be required in order to purchase a product - This is all I can seem to come up with.

Hope someone can help :)

Phorce
  • 2,632
  • 13
  • 43
  • 76
  • What do you mean by "asked to produce a basic Design Pattern for an online commerce system"? Is this some kind of learning exercise? – Tom Anderson Nov 20 '12 at 11:59
  • @TomAnderson Kind of. BUT it's not like I haven't attempted this, I have thought about it, in detail and just want some opinions to what experts think on the proposed pattern – Phorce Nov 20 '12 at 12:00

1 Answers1

0

Hmm, Facade is usually only relevant to provide a simple interface to a hunk of legacy code or a library. It's rarely used for creating new ground-up code, unless you consider "your classes that use library classes such as Lists and Maps" Facades to the library.

http://en.wikipedia.org/wiki/Facade_pattern

"A facade is an object that provides a simplified interface to a larger body of code, such as a class library"

For the task you describe, you would probably be using patterns such as Mediator (could be considered a facade in some cases), model/controller/viewer, Chain of Responsibility (for security), Memento (for presistence) and possibly Builder (for displaying your purchase in several ways: HTML, a PDF invoice, an email...).

Anders Johansen
  • 10,165
  • 7
  • 35
  • 52
  • Thank you for the reply. So you don't suggest me using a Facade pattern here? It seems the most likely from what I was taught about them. I like the idea of the Bulder pattern as well :) – Phorce Nov 20 '12 at 22:58
  • It's often hard to tell the difference beween Facade and Mediator. Telling Facade and Mediator apart is often a matter of intent and circumstances. Mediator usually has a coordinating role for objects that expose a minimum of methods. Facade usually does the same plus hiding a ton of old or overly complex code behind a simpler API. So if your code is new and well-design,ed what you think is Facade is probably Medator once you look closer :) – Anders Johansen Nov 20 '12 at 23:13
  • This answer really illustrates the difference between Mediator and Facade very well. http://stackoverflow.com/questions/481984/facade-vs-mediator?rq=1 Their class diagrams look very alike, and they are often used in the same layer of architecture, but they are really very different. – Anders Johansen Nov 21 '12 at 07:04