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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:44:07+00:00 2026-05-25T20:44:07+00:00

i have designed a function which can return 2 different types based on the

  • 0

i have designed a function which can return 2 different types based on the input parameters

ex: &Foo(12,"count")   -> returns record count from DB for value 12  
    &Foo(12,"details") -> returns resultset from DB for value 12 in hash format

My question is is this a good approach? in C# i can do it with function overload.

  • 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-25T20:44:07+00:00Added an answer on May 25, 2026 at 8:44 pm

    Please think what part of your code gets easier by saying

    Foo(12, "count")
    

    instead of

    Foo_count(12)
    

    The only case I can think of is when the function name (“count”) itself is input data. And even then do you probably want to perform some validation on that, maybe by means of a function table lookup.

    Unless this is for an intermediate layer that just takes a command name and passes it on, I’d go with two separate functions.

    Also, the implementation of the Foo function would look at the command name and then just split into a private function for every command anyway, right?

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

Sidebar

Related Questions

How in EF4 can I make an imported function return a complex type, which
I have Designed the Javascript function My.js it contains following code My.js function display(){
I have designed this gui in netBeans which has a canvas , a couple
I have a Joomla plugin (not important in this context), which is designed to
I have a function which does the following: When the function is called and
I have designed an ASP.NET page which create graphs. I have written a class
I have a simple view function that's designed to allow the user to choose
I have designed a user profile form, a long form which is quite complicated.
I have a sort function which was working fine but then I tried to
I have some code which is designed to replace a value in a list

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.