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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:56:35+00:00 2026-05-14T05:56:35+00:00

The title is hardly understandable, but I’m not sure how to summarize that another

  • 0

The title is hardly understandable, but I’m not sure how to summarize that another way. Any edit to clarify is welcome.

I have been told, and recommended to use interfaces to improve performances, even in a case which doesn’t especially call for the regular “interface” role. In this case, the objects are big models (in a MVC meaning), with many methods and fields.

The “good use” that has been recommended to me is to create an interface, with its unique implementation. There won’t be any other class implementing this interface, for sure. I have been told that this is better to do so, because it “exposes less” (or something close) to the other classes which will use methods from this class, as these objects are referring to the object from its interface (all public methods from the implementation being reproduced in the interface).

This seems quite strange to me, as it seems like a C++ use to me (with header files). There I see the point, but in Java?

Is there really a point in making an interface for such unique implementation? I would really appreciate some clarifications on the topic, so I could justify not following such kind of behavior, and the hassle it creates from duplicating all declarations.


Edit: Thanks everybody for the answers, it was really helpful and instructive (most of them, not only the “accepted” one).

There is clearly no advantage in performance, and I now have a larger scope of the interest that can come from it (depending on the situation), besides the usual OO role of the interface.

  • 1 1 Answer
  • 1 View
  • 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-14T05:56:35+00:00Added an answer on May 14, 2026 at 5:56 am

    Using interfaces has not much to do with performance (except maybe the performance of the development team, i.e. the speed of development). It is more about keeping dependencies under control, and separating unrelated parts of the program.

    If you depend directly on concrete class C in your code, that code is more difficult to unit test, among others. If you instead depend on an interface, it is a snap to create a mock implementation in your unit tests.

    Of course, you may not need to pull up all the methods of your class into the parent interface. In fact, you may not need one single parent interface. Analyze the usage of that class and (especially with a big class like yours) chances are, you find two or even more distinct groups of methods, used by different clients (e.g. one group of clients only queries object state, while the other updates it). This makes it possible to create two or more distinct interfaces, which are much simpler and cleaner each.

    This analysis may even lead to the conclusion that your class is trying to do too many things (instead of having a single responsibility), and you would be better of extracting some of its contents into a separate class! In other words, once you start thinking about – and programming to – interfaces, you start to see design on a different level, and this may lead to better design solutions.

    All this told, if after all the analysis above you still see no use of the interface for your model class, make a note about it. Revisit it after, let’s say, half a year. Then, if you still feel it hasn’t paid for itself, just dump it. Interfaces – like any other element of your program – should always have a clear purpose and a reason to exist (and a better one than “my coworker told me to create it”). They are no panacea. If you use them cleverly, you make your code better. If you use them stupidly, you make your code even worse. The fact that you posted this question here means you want to learn how to use them cleverly, which is good 🙂

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

Sidebar

Related Questions

Title edits that reflect a better summary of the question are welcome. I'd like
I have a problem so strange that I hardly can put an adequate title
I'm sorry for the vague title, but what I want to do can hardly
Title is quite self explanatory, but I have some animation being done in a
Title is a bit ambiguous, but what I mean is: InputStream is = connection.getInputStream();
Title is self-explanatory. I have a good bit of experience with PHP, but I
Title says it pretty much all : is there a way to get the
(Title and contents updated after reading Alex's answer) In general I believe that it's
I hardly even know how to ask this one, but here goes. I have
(Title updated to indicate that problem was with _wgetenv) The following program fails with

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.