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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:16:35+00:00 2026-06-04T21:16:35+00:00

I am designing an API. Here are some example methods from an interface: Entry

  • 0

I am designing an API. Here are some example methods from an interface:

Entry findEntry(int processId);
Entry findEntry(int processId, Filter filter);

where processId refers to some unique identifying information. However I don’t really know what the type of processId is yet.

How can I abstract away an element like id of something?

The best I could come up with is creating a dummy interface:

Entry findEntry(ProcessId id);
Entry findEntry(ProcessId, Filter filter);

However, I worry that with the above approach I may force the client of the API to operate on too high an abstraction level. For example, the equality of process id’s will no longer work (whereas if they used int’s – it would).

Clarification: I failed to clarify that I am writing only the interfaces (contracts), to be implemented later, possibly by a different team. That is why I cannot enforce certain things like equals method.

  • 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-04T21:16:36+00:00Added an answer on June 4, 2026 at 9:16 pm

    Generics is your friend here

    on the method itself if appropriate

    Entry findEntry<TKey>(TKey processId);
    

    or possible the class

    public class EntryFinder<TKey>
    {
      public Entry findEntry(TKey processId)
      {
         // Implementation
      }
    }
    

    Edit: If you’re defining the interface, you can also define this there and leave it to the implemntors of the interface to figure out what type they want to use to identify an Entry.

    public interface IEntryFinder<TKey>
    {
      Entry findEntry(TKey processId);
    }
    

    Usage:

    // Foo's are looked up by integer
    public class FooEntryFinder : IEntryFinder<int>
    {
      public Entry findEntry(int processId)
      {
         // Implementation
      }
    }
    // Baa's are looked up by string
    public class BaaEntryFinder : IEntryFinder<string>
    {
      public Entry findEntry(string processId)
      {
         // Implementation
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am designing an API, and some of the methods return null when they
I am designing an API. It will have a lot of methods which do
I am designing RESTful Api's and would like some advice on designing an API
I'm designing an API interface for a magazine viewer. Something like iGizmo (for iPad).
I am designing an API that is very comparable to Linq (it's a linq
I'm currently designing an API and I came a cross a little problem: How
When designing a C API for configuring a library/utility, I have a co-worker who
I am designing a RESTful API and I would like to know what the
I'm currently (I try to) designing a RESTful API for a social network. But
I am currently designing a public-facing C++ API for a product which will require

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.