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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:11:07+00:00 2026-05-26T00:11:07+00:00

I have an interface that is implemented by thirty concrete classes. The concrete implementers

  • 0

I have an interface that is implemented by thirty concrete classes. The concrete implementers are subdivided into two groups, with each group inheriting from a common abstract class. The abstract classes define the constructors for the concrete implementers, including passing in a database connection object for each “side” of the two sides (they have different databases, among other differences).

All the current interface methods each have several parameters needed for the concrete classes to “get the job done”, but not all are used in every implementer.

When I went to add a new method to the interface this morning, I realized that the database connection is going to be needed for only one of the concrete implementers, but the rest will not need it. So, that gets me wondering, should I pass it in as a parameter? It is needed to “get the job done”, but for only one of the concrete classes, and that class has the database connection already. If I passed the database connection in as an interface parameter, then the other 29 classes will not use it.

What is a good line to draw for what is an acceptable interface parameter? Any reading/content on the subject I will thankfully devour as well.

  • 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-26T00:11:07+00:00Added an answer on May 26, 2026 at 12:11 am

    All the current interface methods each have several parameters needed
    for the concrete classes to “get the job done”, but not all are used
    in every implementer.

    That sounds to me a lot like the interface is slowly turning into a bit of a “god interface”. Check whether this is the case by asking yourself a couple of questions:

    • Does the interface represent a single behavioural concept in your model, or has it become a bit of a convenient dumping ground for method signatures from several concepts? Could it be called something like e.g. Serializable, or would it more accurately be called SerializableAndSomethingElse.
    • Could you carve the interface up into several more cohesive interfaces, and have the 30 different objects implement just the ones they need?

    When I went to add a new method to the interface this morning, I
    realized that the database connection is going to be needed for only
    one of the concrete implementers, but the rest will not need it. So,
    that gets me wondering, should I pass it in as a parameter?

    No. In fact, if the database connection is only needed by one of the implementers then it doesn’t sound like it belongs in the interface at all. The interface should represent the abstract API, where as it sounds as though the database connection is a part of the implementation of that API.

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

Sidebar

Related Questions

We have an interface which will be implemented by classes that take care of
I have an interface, IFindable that is implemented by a few classes. One other
I have written a set of classes and interfaces that are implemented in Moose
If I have interface IFoo, and have several classes that implement it, what is
I'm currently writing a class that implements the SeekableIterator interface and have run into
Suppose you have a COM interface ICOMInterface that is implemented by coclasses Coclass1 and
I'm writing an interface that will be implemented by a lot of classes, and
I have a couple of classes that want to pass each other some information
I have an Strategy interface, that is implemented by StrategyA and StrategyB , both
I have an interface that requires the square brackets operator to be implemented. The

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.