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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:15:07+00:00 2026-06-10T04:15:07+00:00

I am writing a Java API library for an existing REST API. The REST

  • 0

I am writing a Java API library for an existing REST API.

The REST API has a few postOperations (getPosts, getUserPosts, getGlobalPosts etc.)
So I have a class for postOperations that exposes that.
Now I need to add to all the operations the option to add a group of parameters (generalParameters).

What do you think is the better solution?

  1. Add a parameter to the current functions, which means that sometimes the user will have to pass null (it’s actually 80% of the time).
  2. Add an overloading function to every operation that gets 2 parameters (this means adding 6-7 overloading methods to the class)

I know both ways work.
And it’s not a major issue in most applications, but when writing a library other would use it seems a bit more important to me.

What’s your opinion? what is a better api to expose?

  • 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-10T04:15:08+00:00Added an answer on June 10, 2026 at 4:15 am

    I would do something like this:

    public void handle(some parameters) {
        //handle params
    }
    public void handle() {
        handle(null, null, -1, w/e);
    }
    

    Per your edit:

    This code here uses option 2; they will never have to pass a null value if you add another overloaded method which doesn’t take in anything, but passes null for them

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

Sidebar

Related Questions

I have writing Java code Using Jersey library to call Rest APIs. For my
Is there a C or C++ compatible library for reading and writing Java class
I'm writing a library that wraps around a REST API. The wrapper I'm creating
I'm writing a Java wrapper for an API and I have a fundamental question
I am writing a little game with the Java 3D API and I use
I'm writing an XMPP client in Java using the Smack API. I registered a
I am currently writing a Java compiler and have implemented section 15.12.2.7. of the
I'm writing a Java Webapp based on the Google Maps Javascript 3.0 API. I'm
I am writing a networking application using the java.nio api. My plan is to
I'm writing a java application which has to communicate with has to communicate with

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.