There is a lot of content on the web discussing if it is worth defining an interface if only one class implements it. The answers are mostly either Yes, because you probably need to mock it anyways or No, I strongly believe in YAGNI.But what about narrowing the classes public interface?Example:public interface Picture {    public Dimension getSize();    public void resize(Dimension d);    // Some methods to retrieve byte data, etc}public class PictureImpl implements Picture {    // Implement inherited methods    public void setResizeStrategy(ResizeStrategy rs) { ... }}I intentionally do not add the setResizeStrategy(..) method to my interface, because i don't want other classes that accept a Picture object to change the strategy for resizing (think of linear upscaling vs using a technique such as antialiasing).I essentially narrow the public interface of PictureImpl for the rest of my program, since it only uses the Picture interface (following the programming to an interface, not an implementation method).I can then hide the actual PictureImpl construction in some kind of creating container, like a factory:public class PictureFactory {    public Picture createPicture() {        PictureImpl p = new PictureImpl();        // Search for a library that can resize pictures        // If a library is found that we can support return the corresponding strategy        // If no library is found, use our self coded linear upscale strategy        ResizeStrategy strat = ResizeStrategyResolver.findBestStrategyAvailable();        p.setResizeStrategy(strat);        return p;    }}Is this a valid use case for interfaces, or am i misusing the technology?Note: I know that one could argue that changing the strategy during runtime might be a desired feature. I couldn't come up with a better example on the spot. I hope you get the point i am trying to make.
Using java interfaces to narrow the classes public interface
java;design;interfaces