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 9247687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:47:37+00:00 2026-06-18T09:47:37+00:00

public class ConcreteService1: IService1 { private IService2 _service2; public void doSomething() { _service2 =

  • 0
public class ConcreteService1: IService1
{
private IService2 _service2;
public void doSomething()
{
   _service2 = new ConcreteService2();
 .....
}


}

 public class ConcreateService2: IService2
{
private IService1 _service1;
public void doSomething()
{
 _service1 = new ConcreteService1();
 .....
 }

}

Is this is the situation that Factory or Abstract factory can be used here. If yes can you please provide an example.

  • 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-18T09:47:38+00:00Added an answer on June 18, 2026 at 9:47 am

    In your case as you have two classes with two different interfaces then Factory really doesn’t apply here. you should use abstract factory as
    its an object and which delegates the object initialization to its separate functions.

    Abstract Factory Interface for your example goes here

    public Interface IAbstractInterfaceFactory
    {
    
    IService1 InitializeService1();
    IService2 InitializeService2();
    
    }
    

    Factory pattern is used generally when you have too many different object initialization implementing same interface or abstract class. The pattern suggest to have a Factory method and based on type of object need to be initialized it creates the specific object and return it.
    It helps in two ways
    1. Keeps all the initialization code at one place
    2. It never returns the concrete class which makes it more extendable and manageable

    For more information please see this links
    Differences between Abstract Factory Pattern and Factory Method
    http://en.wikipedia.org/wiki/Abstract_factory_pattern
    http://www.codeproject.com/Articles/68670/The-Factory-Pattern
    http://en.wikipedia.org/wiki/Factory_method_pattern

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

Sidebar

Related Questions

public class Test { public static void main(String[] args) { DemoAbstractClass abstractClass = new
public class XPBN extends Activity{ private Map _map; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState);
public class Pojo { private String value; public static void printValue() { System.out.println(value= +
public class BaseFoo { private string param; public BaseFoo(string param) { this.param = param;
public class Example { public Example duplicate; public void duplicateState() { this.example = this.clone();
public class UnitTest1 { [TestMethod] public void TestMethod1() { var key = new Dictionary<string,
public class A { private void sub() { add(); } private void add() {
public class ParserGUI extends javax.swing.JFrame { public ParserGUI() { initComponents(); } private void initComponents()
public class Simulation extends Thread { private volatile boolean loopState = true; public void
public class FBPost extends Service{ private Bundle params = new Bundle(); private String userID=;

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.