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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:26:47+00:00 2026-06-07T13:26:47+00:00

This question is coming from a javascript point of view, but it certainly could

  • 0

This question is coming from a javascript point of view, but it certainly could apply to other languages.

I have been running into this more and more lately, and was wondering if there was a best practice, or at least good design standard, for when how to build your methods.

The obvious options that I see are as follows, along with a trivial example for each

  • Multiple methods:

    this.makeGetRequest = function(controller){...}
    this.makeSynchronousGetRequest = function(controller){...}
    this.makePostRequest = function(controller, data){...}
    
  • One method, with more parameters:

    //data would be an optional parameter
    //  this.makeRequest("friends", "GET", true);
    //  this.makeRequest("friends", "POST", false, newFriend);
    this.makeRequest = function(controller, type, isSynchronous, data){...}
    
  • One method, with an options parameter:

    this.makeRequest = function(controller, type, options);
    this.makeRequest("friends", "POST", {data:newFriend, isSync:false});
    

The HTTP requests example is just motivated the question, but this works for any public facing function with varying amounts of customization/variables.

All three are obviously just as functional. But what’s good practice? Is there a standard, or guideline that tends to be followed?

  • 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-07T13:26:49+00:00Added an answer on June 7, 2026 at 1:26 pm

    The advantage of the options parameter is that it allows unlimited options without sacrificing clarity. When someone specifies data: or isSync: it’s plainly obvious what settings are being filled in. Remembering to set the 13th parameter in a function to false is a recipe for confusion.

    So, between the last two options I only use multiple parameters in cases where (1) there are fewer than four parameters in total, (2) the sequence is logical and easy to remember (URL, then type, then data), and (3) no more than one (the last one) is optional. That’s as a rule of thumb, anyway.

    How about multiple methods versus parameterization? Multiple methods is only an option to begin with when you have a small number of possibilities (GET vs. POST, UseDefaults vs. DontUseDefaults, or whatever). Thinking about it, I’m likely to setup separate methods only when:

    1. The distinction is highly important (a synchronous request behaves fundamentally different from an asynchronous request and I want the developer consciously choosing which to apply. (Whereas by contrast GET vs. POST is just one more property of your request — it’s not an end-all, deal-breaking decision if you do it wrong.)

    2. There aren’t other options you’ll want to set anyway. If I first have to remember whether to call foo.get() or foo.post() and then remember to fill in an options object anyway, I’m just forcing you to make decisions in two different places. I’d rather have all the settings in one place.

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

Sidebar

Related Questions

I'm coming largely from a c++ background, but I think this question applies to
Coming from this question , I have a wxComboCtrl with a custom popup made
Apologies for the very basic question - crash course in javascript coming up! But
I am following up from this question here The problem I have is that
This question is more UI/Design-ish than hard-core programming is. Background: I've been coding in
I have just a question... I'm seeing this coding style in various php scripts
I'm coming to javascript from C background. In javascript, when I use the assignment
This is a complete noob question, but I gotta ask it anyway I started
I have seen this question , and using its method throws up an error
I have a question regarding JavaScript and methods by which its code can be

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.