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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:18:15+00:00 2026-05-23T00:18:15+00:00

Ok I will try to explain this as much as possible. I have a

  • 0

Ok I will try to explain this as much as possible.
I have a class, say MyLib, the methods of which will be used by another class, say Consumer class.
There is a public method called Navigate() in MyLib, which will be used by Consumer. This method sort of provides a level of abstraction for Consumer, as it can provide different types of navigation using just this method. The following code snippet provides the needed code map.

// this method will be exposed to the consumer class.
public bool Navigate (NavigationType type)
{ 
    // this method will decide which private _navigateToXyz() method will be called.
    switch (type)
    {
       case x: return _navigateToX();
       case y: return _navigateToY();
       case z: return _navigateToZ(arg1, arg2);
       case a: return _navigateToA(arg3);
    }
}

private bool _navigateToX() { }
private bool _navigateToY() { }
// two or three additional _navigateTo_() without any parameters
private bool _navigateToZ (arg1, arg2) { }
private bool _navigateToA (arg3) { }

As shown above, all but two private methods requires some arguments to be passed. So if I follow this approach, then I essentially have to pass those arguments in Navigate() as well – those arguments that none of the other methods have to do anything with.

I am doing this way right now. But I want to know if there is a better approach possible in this situation?

UPDATE : After some more brainstorming, I think that Navigate() method is not that required, since it pretty much just calls an appropriate method based on the passed navigationType. Now, the navigationType being known by the caller of Navigate(), he could himself call the very method required, if those methods are exposed as public. I hope I am clear. So do optional parameters matter at all now? Method overloading makes more sense?

  • 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-23T00:18:16+00:00Added an answer on May 23, 2026 at 12:18 am

    Have multiple public versions of the method. That will make way more sense to consumers looking at this through intellisense.

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

Sidebar

Related Questions

I think this may not be possible, will try and explain as best as
Hmm. I found this which seems promising: http://sourceforge.net/projects/mjpg-streamer/ Ok. I will try to explain
This might be a little hard to explain, but I will try. I want
I will try to explain myself as best as possible, I know the title
sorry for asking this dumb question i will try to explain as good as
I will try to explain this in a different way so it makes more
I will try and explain my problem as accurately as possible, I don't think
I'm fairly new to C# but I will try to make this quick! ;)
I'm try to develop a regex that will be used in a C# program..
I am about to try and automate a daily build, which will involve database

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.