Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8126423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:08:37+00:00 2026-06-06T07:08:37+00:00

I know this question was asked for many times, and it may look like

  • 0

I know this question was asked for many times, and it may look like the question is a duplicate, but i tried to understand the posts on SO, Google, GoF and didn’t found the answer for me…

I understand the difference between the Factory Method and Builder:
Factory Method – Creates objects that derive from a particular base class, decoupling concrete implementation from client

Builder Method – Hides the complexity of the object creation from client

Now I see example that i found on internet (Abstract Factory Design Pattern for Dependency Injection), it’s about an Abstract Factory, but it doesn’t matter for my question. It’s just one of many articles that i viewed

//Abstract Factory for Dependency Injection
//Factory interface
public interface Module1ServiceFactory {
 ComponentA getComponentA();
 ComponentB getComponentB();
}

//Concrete factory
public class Module1ServiceFactoryImpl {
 private Module1ServiceFactory instance;

 private Module1ServiceFactoryImpl() {}

 public static synchronized Module1ServiceFactory getInstance() {
  if (null == instance) {
   instance = new Module1ServiceFactoryImpl();
  }

return instance;
 }

*** SUBJECT METHOD ***
 public ComponentA getComponentA() {
  ComponentA componentA = new ComponentAImpl();
  ComponentB componentB = getComponentB();
  componentA.setComponentB(componentB);
  return componentA;
 }

 public ComponentB getComponentB() {
  return new ComponentBImpl();
 }
}

What I see in that example, ComponentA is a complex type that getComponentA() method used to build it.

  1. So why this is called Factory and not Builder??? Or it means that Module1ServiceFactoryImpl implement Factory AND Builder patterns?
  2. Is it correct (commonly used) to create classes/objects that implements more than one design pattern in software architecture design?

And sorry for my English 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:08:39+00:00Added an answer on June 6, 2026 at 7:08 am

    So why this is called Factory and not Builder??? Or it means that
    Module1ServiceFactoryImpl implement Factory AND Builder patterns?

    It’s called factory, because it’s factory, and only factory

    *** SUBJECT METHOD ***
     public ComponentA getComponentA() {
      ComponentA componentA = new ComponentAImpl();
      ComponentB componentB = getComponentB();
      componentA.setComponentB(componentB);
      return componentA;
     }
    
     public ComponentB getComponentB() {
      return new ComponentBImpl();
     }
    

    I see no builder here. Sure, this isn’t simplest approach, but it’s definitely not that complex as it would be, if builder pattern were introduced. This is more like JavaBean-way and using setters on freshly created object. Builder pattern requires creation of object in last step, to make it impossible for creating object to be in state between ready-to-use and not-ready-yet.

    Is it correct (commonly used) to create classes/objects that
    implements more than one design pattern in software architecture
    design?

    Yes, it’s correct and used, sometimes. Not that commonly, because every pattern adds some complexity, and multiple patterns add multiple complexity 🙂 But, of course, you can mix builder with factory (builder needs some parts that are factored), facory with builder (factory encapsulates usage of create objects with builder). Patterns are good in working together. MVC is good sample:

    The GoF (Gang of Four) do not refer to MVC as a design pattern, but rather consider it a “set of classes to build a user interface”. In their view, it’s actually a variation of three other classical design patterns: the Observer (Pub/Sub), Strategy and Composite patterns. Depending on how MVC has been implemented in a framework, it may also use the Factory and Decorator patterns.

    http://addyosmani.com/blog/understanding-mvc-and-mvp-for-javascript-and-backbone-developers/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked many times before but I tried out
I know this question has been asked many times, but my problem is a
I know this is a question that has been asked many times before, but
I know this question is asked many times but I just want to clear
I know this question was asked many times, but still my problem is not
I know this question was being asked many times but I want to be
I know this question has been asked many times, but I am having trouble
I know this question has been asked many times. But from what I read,
I know this question has been asked many times, but I have not been
This may be a very old, many times asked question. But I am not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.