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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:49:44+00:00 2026-05-18T11:49:44+00:00

I have a series of static utility methods of this form: StringBuffer Util.doA(String arg0,

  • 0

I have a series of static utility methods of this form:

StringBuffer Util.doA(String arg0, String arg1, SomeEnum e);  
StringBuffer Util.doB(String arg0, String arg1);  
StringBuffer Util.doC(String arg0, String arg1, String arg2,String arg3);  
StringBuffer Util.doD(String arg0, String arg1, String arg2,String arg3, AnotherEnum e);  
etc

I want to display a JDialog that is created dynamically e.g. via builder or other pattern and once a button is pressed I want the appropriate utility method to be called depending on the type of dialog.
E.g. If JDialog is of type A the actionlistener of button should call the Util.doA passing as arguments data from the input fields and if JDialog is of type B I want the actionlistener of button to call Util.doB etc.
Types A, B etc are my custom types. Are not mandatory to be used. I just have them to distinguish between each JDialog.
JDialog of type A differs from JDialog of type B in some of the input fields. But the overall appearance is similar.
Totally there are about 20 types and 20 corresponding util methods.
Is there a standard pattern to this problem I have?
I started extending JDialog so that each custom JDialog creates itself properly and the method of actionlistener calls the appropriate utility method, but I end up with 20 new classes.
So I thought if there is a better approach to this.
Any ideas?

Thank you

  • 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-18T11:49:45+00:00Added an answer on May 18, 2026 at 11:49 am

    Put the corresponding util method inside the 20 types. If there is any duplication between the types you might be able to move it to a super class.

    As to your question, I think this is the optimal approach in your case. If you have the dialog and util code all in one class and nothing more, then it is clear what that class’s purpose is. It also means that if you need to remove, change, add a new type you are only having to delete one class, modify one class, or create one new class. Keeping all the related code together prevent’s “Shotgun surgery”.

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

Sidebar

Related Questions

I have a series of static methods to modify a collection then return the
I have a series of Extension methods to help with null-checking on IDataRecord objects,
I have a series of NX objects (e.g., a static bool array of dimension
I have a variable declared as: private static List<String> _search_result_list = new ArrayList<String>( 15
I have a set of about 2000 separate time-series in the form of SortedList<DateTime,double>
I have this bit of code that is receiving a series of messages: byte[]
I have defined a series of Routes in Global.asax.cs: public static void RegisterRoutes(RouteCollection routes)
I have a series of PDFs named sequentially like so: 01_foo.pdf 02_bar.pdf 03_baz.pdf etc.
I have a series of functional tests against a web application that correctly run,
I have a series of performance tests I would like to show as a

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.