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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:30:17+00:00 2026-05-27T16:30:17+00:00

I have always had a hard time understanding the real value of Interfaces when

  • 0

I have always had a hard time understanding the real value of Interfaces when coding with Objects in PHP (could be other languages I imagine)

From what I understand you use an Interface to enforce or guarantee that when a Class is using an Interface that that class will have the methods defined in the Interface inside of that class.

So from my litte knowledge of using them, wouldn’t that mean you would only find an Interface beneficial when defining more then 1 class that needs those Methods?

To be more clear, if I have a class that does one thing and no other classes need to do that kind of thing, then it would be pointless to use an Interface on that class?

So you wouldn’t use an Interface on EVERY class you right?

PS) If you vote this question as exact duplicate then you didn’t read the question and only the title as I have read most of the similar questions already

  • 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-27T16:30:18+00:00Added an answer on May 27, 2026 at 4:30 pm

    From what I understand you use an Interface to enforce or guarantee
    that when a Class is using an Interface that that class will have the
    methods defined in the Interface inside of that class.

    This is actually only half of the deal (the technical part). There’s also the all-important architectural half, which appears when you consume the interface and it goes like this:

    function feed(IAnimal $interface) {
        // ...
    }
    

    (alternatively, a “factory” function that is documented to return an instance that implements IAnimal would also serve as an example).

    The idea here is that the consumer of the interface says: “I want an animal to feed. I don’t care if it flies, walks, or crawls. I don’t care if it’s big or small. I only care that it shares some features with all other animals” — features that would comprise the definition of the interface.

    In other words, interfaces serve to abstract the contract (interface) from the concrete implementation (classes). This gives implementers of concrete classes a free hand to modify, rename, remove and add implementations without breaking the code for users of the interface, something that is not possible if you are referencing concrete classes directly in your API.

    As for the interface that is implemented by one class only: that’s not enough information to decide. If there can plausibly be more implementations of the interface in the future, then it certainly does make sense (for example: an IHashFunction interface would make sense even if Sha1HashFunction were currently the only available implementation). Otherwise it doesn’t offer anything.

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

Sidebar

Related Questions

We have always had languages that were preferable to be used in a particular
I have always had an interest in coding, and a while back a started
I have modified a working Windows service that had always been starting beforehand. After
I've had a hard time trying to find good examples of how to manage
this is something I have always had confusion about I never can seem to
I have always had issues with identifying the errors in applications from the error
When defining datatypes in a database, I have always had a problem with choosing
I have always thought that the .equals() method in java should be overridden to
I have always used || (two pipes) in OR expressions, both in C# and
I have always wondered how people update a previous line in a command line.

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.