mercredi 19 avril 2017

How to use Composition Design Pattern?

I have an Interface Item which will be used by 1 client who worries just about rank and another client other methods along with this rank.

My code looks like:

public interface Item {
    RankedPage rank(final PageContext pageContext) throws ItemException;
}


public interface TestItem extends Item {

    void test();
    void doneTesting();


    void train();
    void doneTraining();
}

The Clients uses an interface to get the ItemRequest they want.

public interface ItemBuilder {
    Item buildItem(final ItemRequest ItemRequest) throws ItemException;

    TestItem buildTestItem(final ItemRequest ItemRequest) throws ItemException;

}

How do I do this better with any design pattern? Can I use composition DP?

Aucun commentaire:

Enregistrer un commentaire