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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:42:42+00:00 2026-05-27T14:42:42+00:00

I have the following interface called IAccountService. I also have exactly the same interfaces

  • 0

I have the following interface called IAccountService. I also have exactly the same interfaces for Product and Package etc.

public interface IAccountService
    {
        void AddOrUpdate(Account account);
        void Delete(Account account);
        bool DoesTableExist();
        Account Get(Account account);
        Account Get(string pk, string rk);
        IEnumerable<Account> Get();
        IEnumerable<Account> Get(string pk);
        string GetOptions(string pk, string rk);
        IEnumerable<AccountDetail> ShowDetails(ref string runTime);
        IEnumerable<AccountSummary> ShowSummary(ref string runTime);
        void ValidateNoDuplicate(Account account);
        void ValidateNoProducts(Account account);
    }

I created some generic methods but I am wondering can I also create a generic interface. If so then how would I call it and how could I change the above to make it generic. Presently I use this interface as follows:

public class AccountService : BaseService, IAccountService

Update 1

Thanks for all the suggestions. The one thing I still have a problem with is AccountDetail and AccountSummary classes. I am thinking maybe these should be sub classes. But how then can I handle the naming of those? I would have to take the class name, append Detail and then use that in the interface. IS that possible?

Update 2

Here’s an example of the detail and summary classes:

public class AccountDetail
{
    public string Title { get; set; }
    public string Product { get; set; }
}
public class AccountSummary
{
    public string Title { get; set; }
    public Int32? ProductCount { get; set; }
    public string PartitionKey{ get; set; }
    public string RowKey { get; set; }
    public DateTime? Modified { get; set; }
    public string ModifiedBy { get; set; }
}

The above classes are used for reporting. I am thinking that they probably should not be part of the model repository. Maybe they should be in another place.

Regarding the ref comments. The ref is there because in my controller I call the following method:

_account.ShowDetails(ref runTime);

The output of ShowDetails is a list of details and the runTime reference is updated with the time that it takes to run the report.

  • 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-27T14:42:43+00:00Added an answer on May 27, 2026 at 2:42 pm

    Something like this?

    public interface IService<T, TDetail, TSummary>
    {
        void AddOrUpdate(T entity);
        void Delete(T entity);
        bool DoesTableExist();
        T Get(T entity);
        T Get(string pk, string rk);
        IEnumerable<T> Get();
        IEnumerable<T> Get(string pk);
        string GetOptions(string pk, string rk);
        IEnumerable<TDetail> ShowDetails(ref string runTime);
        IEnumerable<TSummary> ShowSummary(ref string runTime);
        void ValidateNoDuplicate(T entity);
        void ValidateNoProducts(T entity);
    }
    

    A few things to note:

    1. There appeared to be three distinct types to be generalized, so there are three corresponding type parameters. If the latter two aren’t correct, go ahead and update or let me know and I can help with that.
    2. I renamed parameters to “entity” as a more generic term. You can choose whatever name makes sense to you.
    3. Are the last two method names generic enough for this? ValidateNoProducts seems suspect to me if it also exists on the Product version of this interface.

    All in all, while it’s possible to make a single generic interface, one important question you need to ask yourself is if this is indeed the right abstraction. Some of these methods might be intuitively more type-specific and belong on a different type of service.

    To that end, you can create an IService<> with most of these methods and then have your AccountService and other services which implement it also add methods of their own. That would seem like a more viable abstraction, as opposed to trying to fit a square peg into a round hole with incorrect abstractions.

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

Sidebar

Related Questions

Consider I have the following interface: public interface A { public void b(); }
I have defined the following Interface [ServiceContract] public interface IHealthProducts { [OperationContract()] ResponseClass OrderSelfSignedHealthCertificate();
I have the following classes public interface InterfaceBase { } public class ImplementA:InterfaceBase {
Let's say I have the following code: interface ISomeInterface { void DoSomething(); void A();
I have created the following interface public interface ISolutionSpace { public boolean isFeasible(); public
I have an interface named IAuthorizationRepository with the following interface: public interface IAuthorizationRepository {
I have the following code: // IMyInterface.cs namespace InterfaceNamespace { interface IMyInterface { void
I have the following problem. Given a Interface EventNotifier for the Observer Pattern: public
I have the following method: -(void)SomeMethod:(id)classOrProtocol; It will be called like this: [self someMethod:@protocol(SomeProtocol)];
I have the following interface which I'm trying to make COM-visible. When I try

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.