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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:05:25+00:00 2026-05-13T22:05:25+00:00

I am very interested in using the Passive View pattern to improve testability, but

  • 0

I am very interested in using the Passive View pattern to improve testability, but I am not sure how to call child dialogs.

Do you have the parent view create the child view and return an interface to the parent controller, then have the parent controller create the child controller?

  • 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-05-13T22:05:25+00:00Added an answer on May 13, 2026 at 10:05 pm

    I have been thinking about this a lot and I think I have a couple of possible solutions.

    1. Add a method to the view class to generate the subordinate dialog
    2. Create a factory that generates the model, view. and controller for the subordinate dialog

    Method 1

    class ParentView extends JDialog implements IParentView {
      public IChildView newChildView(...) {
        return new ChildView(...);
      }
      // ...
    }
    
    interface IParentView {
      IChildView newChildView(...);
      // ...
    }
    
    class ParentController {
      private IParentView view;
      public ParentController(IParentView view) {
        this.view  = view;
      }
    
      public void showChildView() {
        IChildView childView = view.newChildView();
        ChildController childController = new ChildController(childView);
        childView.setVisible(true);
      }
    }
    
    class ChildView extends JDialog implements IChildView {
      // ...
    }
    
    interface IChildView {
      void setVisible(boolean visible);
    }
    
    class ChildController {
      private IChildView view;
      public ChildController(IChildView view) {
        this.view = view;
      }
    }
    

    Method 2

    // During testing, create a mock ChildFactory and assign it to instance
    class ChildFactory implements IChildFactory {
        private static IChildFactory instance;
        public static ChildFactory getInstance() {
          if (instance == null) {
            instance = new ChildFactory();
          }
          return instance;
        }
        public static void setInstance(IChildFactory factory) {
          instance = factory;
        }
        public void createChild(IParentView parent) {
          IChildView view = new ChildView(parent);
          ChildController controller = new ChildController(view);
          view.setVisible(true);
        }
    }
    
    interface IChildFactory {
      void createChild(IParentView parent);
    }
    
    class ParentController {
      private IParentView view;
      public ParentController(IParentView view) {
        this.view  = view;
      }
      public void showChildView() {
        ChildFactory.getInstance().createChild(view);
      }
    }
    
    // ParentView class similar to method 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have very interested in using MongoDB it seems awesome. But I'm from a
I am very interested in using one of the products to do migration but
I am very interested in using CI phonegap and jquery to make mobile apps,
I'm a Rails noob very interested in experimenting with mobile app development using trigger.io.
I am very interested in postgesql because they have a uuid data type. I
I am very interested in mobile application development. But which language or framework is
I've been using Tomcat for years, but I have been put on a new
I am very interested in using MongoDB for a variety of reasons. It suits
OK maybe this is a trivial issue but I'm very interested to see if
I'm very much interested in the acts_as_commentable gem, but by looking at it I

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.