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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:17:28+00:00 2026-06-18T15:17:28+00:00

I am trying to build an application that handles making lots of API requests

  • 0

I am trying to build an application that handles making lots of API requests to 2 or 3 related APIs. My general strategy is to have one base class ApiRequest that has:

List<Parameter> Parameters
Uri CombinedUri
string Results
string _Host

and methods:

CombineUri() //combines the _Host and parameters into full Uri
MakeRequest() //makes the request and stores Results

Then I would inherit that base class into many different Api Calls and implement functions in those specific to that Api call.

The problem I have is that I call CombineUri() in my base classes constructor, but it requires that _Host already be set. However, I want _Host to be a constant in each child class since it is specific for each different Api call. I do not want to have to remember to call CombineUri from every derived class’ constructor.

Any ideas to get around that problem would be greatly appreciated. Also, if you have a different design idea entirely for implementing a base for Api calls I would be all ears. I am not sure my approach is the best.

Thanks.

My Solution:

I implemented ideas from both John and Colin Pear.
I changed the base ApiRequest into an abstract class, and I moved the CombineUri() method into the MakeRequest() method.

I also went further and changed ApiRequest into a generic class and changed _Host into a static string. This way, each subclass with subclass ApiRequest<*subclassname*>. Due to the properties of generics, each object of a particular subclass will share a static _Host.

  • 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-18T15:17:30+00:00Added an answer on June 18, 2026 at 3:17 pm

    How about making CombineUri() private and then call it inside the implementation of MakeRequest().

    The user of this class should not have to know that they need to call two methods, and furthermore, that they have to call CombineUri before they call MakeRequest. That’s an implementation detail that belongs inside MakeRequest.

    It’s possible I don’t fully understand the classes, but if I do, then I would make CombineUri private and always call it as the first part of MakeRequest.

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

Sidebar

Related Questions

I have an application that I'm trying to build with at least a nominally
I'm trying to build application that could help me dial a contact just like
I'm trying to build an application that builds a resource file into a jar,
I'm trying to build a application that has different kinds of users, I'm using
i'm trying to build an application that every given time, will connect to a
I am trying to build a Python application that connects to Oracle database and
I'm trying to build a web application that uses an SSL connection. So I
I'm trying to build an iPhone application that has two subviews in the main
as titled, am trying to build a small application that will aggregate RSS from
I'm trying to build a simple GAE application that would read a textbox, pass

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.