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

  • Home
  • SEARCH
  • 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 9296855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:55:32+00:00 2026-06-18T21:55:32+00:00

Below is an attempt to create a reusable solution for the control break pattern.

  • 0

Below is an attempt to create a reusable solution for the control break pattern. It is built on Command Pattern (Action and Test interfaces). However, I realized my old COBOL thinking got in the way, because this solution is predicated on each of the Action and Test objects having access to “global variables.” And my immediate thought after that was “the need for variable access like this (wider scope) must be an already invented wheel.

How to give all the Actions and Tests below access to a group of variables — an indeterminate group because this is supposed to be a reusable solution??

public class ControlBreak {

public static void controlBreak(Action initialize, 
                                Test   endOfInput, 
                                Test   onChange, 
                                Action breakAction, 
                                Action detailAction, 
                                Action getNext) {

    boolean hasProcessed = false;

    getNext.execute();
    for (initialize.execute();endOfInput.test();detailAction.execute(),getNext.execute()) {
        hasProcessed = true;
        if (onChange.test()) {
            breakAction.execute();
        }
        detailAction.execute();
    }
    if (hasProcessed) {
        breakAction.execute();
    } else {
        // throw empty input exception
    }
}
}
  • 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-18T21:55:34+00:00Added an answer on June 18, 2026 at 9:55 pm

    On a few re-reads, it seems like you’re trying to abstract a certain control flow, where the parameters can be coupled. In this case, I’d look into generics. I.e. something like this:

    public static void <TParams> controlBreak(Action<TParams> initialize, ..., TParams params) {
        // ...
        initialize.execute(params)
        // ...
    }
    

    That way this method will remain reusable, but the various actions / tests can still accept a strongly-typed set of parameters/variables. (The concrete type of TParam.)

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

Sidebar

Related Questions

I'm getting the error below when I attempt to create a table with a
Below is my attempt to turn a System.Diagnostics.Process into an IConnectableObservable. This solution has
Below is an attempt I've made to create a procedure that returns the function
When I attempt to create the stored procedure below I get the following error:
I'm trying to create a custom control with C#/WPF. See below for the XAML
How would i add key commands to the sprite plumbers? Below is my attempt
When I attempt to run the script below in Eclipse(PyDev): import subprocess subprocess.call(/usr/local/bin/mitmdump) An
Below is the code I am using and the error happens when I attempt
When the Action method below attempts to return the Json result no data object
Please have a look at the schema below: CREATE TABLE Person (id int 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.