mardi 23 février 2021

E-Commerce low level design of Order class

I am in middle of shopping website design. As of now I am stuck at one point and need a little feedback. Let us say I have an order class defined as follow:

class Order {

    Payment payment;
    Address ShippingAddress
    int orderId;
    List<Item> orderItem;
    double orderValue;  
    Buyer buyer;
    Date orderDate;
    NotificationService notificationService;
    Shipment shipment;
    
    List<OrderLog> orderLog;

    public OrderStatus placeOrder();
    public OrderStatus trackOrder();
    public void addOrderLogs();
    public PaymentInfo makePayment();
    public int createShipment();

}

Does it make sense to have placeOrder(), makePayment() etc.,API in order class? Or shall I make a separate OrderManager that helps to do all order related stuff and order will act as a pojo?

To me first one seems correct because the placeOrder(), makePayment() seems to me as behaviours of order and they should be in order class but on other class I think it is too much for an order class to do.Am i violating some SOLID principle by taking one approach over another?

Aucun commentaire:

Enregistrer un commentaire