Categories

Aug 12 in Design Patterns
Q:

Q. What is Factory pattern?

1 Answer

Aug 12

Factory pattern is one of most used design pattern and comes under creational patterns category.

In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.

image


**Pro's**:

  • Allows you to hide implementation of an application seam (the core interfaces that make up your application)
  • Allows you to easily test the seam of an application (that is to mock/stub) certain parts of your application so you can build and test the other parts
  • Allows you to change the design of your application more readily, this is known as loose coupling

Con's

  • Makes code more difficult to read as all of your code is behind an abstraction that may in turn hide abstractions.
    • Can be classed as an anti-pattern when it is incorrectly used, for example some people use it to wire up a whole application when using an IOC container, instead use Dependency Injection.
Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

Madanswer
Oct 16, 2019 in Design Patterns
Aug 12 in Design Patterns
Aug 12 in Design Patterns
...