Reputation: 26473
I have such design:
public interface MyInterface {
public abstract List<Sth> getSth();
}
public class MyConcreteImplementation implements MyInterface {
private ConcreteSth mSth = new ConcreteSth();
public List<Sth> getSth(){
return mSth.getSth(additionalParams);
}
}
Purpose of code above is to provide unified method to be called from other classes.
Can this be called a pattern? If so how to name it?
Upvotes: 2
Views: 216
Reputation: 597124
It looks to me like an Adapter. It adapts ConcreteSth
to MyInterface
.
Anyway, if it does the work you expect from it, you should be asking about whether it's a pattern only out of curiousity.
Upvotes: 5
Reputation: 24788
Purpose of code above is to provide unified method to be called from other classes.
That's really sound like Adapter. You want to have a certain class adapted to your interface. The interface here is MyInterface
and the adaptee is ConcreteSth
.
Upvotes: 1
Reputation: 44073
You are just following basic object oriented design here. This looks like simple Composition to me and if you are really keen on a design pattern I could stretch it to being a form of delegate.
Upvotes: 3
Reputation: 41509
I would call it an Adapter: it wraps another method (MyInterface.getSth
) around an existing interface (i.e. the ConcreteSth
), without changing the functionality.
Upvotes: 0
Reputation: 1017
Factory method?
The essence of the Factory method Pattern is to "Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses."
http://en.wikipedia.org/wiki/Factory_method_pattern
Upvotes: -2