Nameless
Nameless

Reputation: 279

Use Cases with single dependency in Clean Architecture

Is it worth to create a Use Case class when it has only one single dependency and its execution just call a method of that dependency?

public class GetOrdersUseCase {
    private OrdersManager ordersManager;

    public GetOrderUseCase(OrdersManager ordersManager) {
        this.ordersManager = ordersManager;
    }

    public List<Order> execute() {
        ordersManager.getOrders();
    } 
}

Upvotes: 3

Views: 257

Answers (1)

Haroldo_OK
Haroldo_OK

Reputation: 7270

Yes, in order to simplify future maintenance, since one of the main concepts behind the Clean architecture is that there should be a one-to-one mapping between your use case classes and the use cases in the documentation. It makes easier to discover which classes implement what.

Upvotes: 3

Related Questions