-2

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?

5
  • can someone tell me what kind of software engineering stuff we should ask here?As i see there are only dislikes here. – rahul sharma Feb 23 at 17:40
  • Your question would be a better one if you stopped worrying about SOLID and actually asked a software design-related question. There's no such thing as "correct" in software development; there are only better or worse ways, for some definition of better or worse. – Robert Harvey Feb 24 at 17:15
  • I know this. Thtat's why I did not say A approach is better than B.I was just wanted to know what other people think of approaches i mentioned.There is never a single answer to a "Software engineering" problem or more broadly CS related problem. – rahul sharma Feb 24 at 18:20
  • You don't seem to have stated an actual problem. – Robert Harvey Feb 24 at 18:21
  • yeah i agree. I would have framed it in a better manner.I would take care next time:) – rahul sharma Feb 24 at 18:24
0

github.com is "your bestest friend!" Go to that site and search for "e-commerce websites" in your language of choice. If you do not thereby find an existing project that "teleports you 95% of the way," such that you can "kit-bash" it into exactly what you need, at the very least you will find concrete implementations which worked well for other people.

Actum Ne Agas: Do Not Do A Thing Already Done.™

As a somewhat-unrelated example, I was able to find "a complete trouble-ticket management system," more than a year-and-a-half in development by the kind soul who shared it on github. By re-doing the data models and the screen templates to suit my client's expectations, I was able to give them the benefit of "a ticket management system a year-and-a-half in the making" in about one month. Thanks to one generous soul.

"Shopping websites have been done to death." You don't have to "begin at the beginning" anymore.

1
  • i understand you points. But i want to understand this concept from software engineering perspective. I can anyhow find template online to do this.Even i can build them by somehow to get required task done. But from an architect perspective, i am looking to gain some more deep insights.Most of online stuff give some example and get away.This is probably by far great community for me that does this stuff but it feels low when people come and click downvotes. – rahul sharma Feb 23 at 19:49
0

There's a lot of functionality being put into Order, with no obvious requirement for any workflow. You have to create an Order before you can call placeOrder. Can you track an order that hasn't bee placed, or pay for it?

I would normally consider an order to be a collection of data; something that could be an entry in a database.

I would be putting the "business logic" somewhere else.

Not the answer you're looking for? Browse other questions tagged or ask your own question.