In Java, is there a gain in using interfaces for complex models?
Posted
by Gnoupi
on Stack Overflow
See other posts from Stack Overflow
or by Gnoupi
Published on 2010-04-14T12:41:40Z
Indexed on
2010/04/14
12:43 UTC
Read the original article
Hit count: 216
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 method 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.
© Stack Overflow or respective owner