lundi 26 février 2018

Adapter pattern without passing class object as parameter

I have a really simple question. There are examples of adapter pattern on internet and in every one of them adapter class get object of class that needs to be adapted as parameter. Something like this:

class Adapter {
    private SomeClass someClass;

    public Adapter(SomeCLass someClass){
        this.someClass = someClass;
    }

    public adaptMethod(){
        ...
    }
}

If I do something like this:

class Adapter {
    private SomeClass someClass;

    public Adapter(){
        this.someClass = new SomeClass();
    }

    public adaptMethod(){
        ...
    }
}

Would this still be an adapter pattern?

Aucun commentaire:

Enregistrer un commentaire