spree/spree — pull request #1771 by radar (2012-07-16 06:59:53+00:00)
Title: Order split

This issue is kind of related to #1766. Pinging @cmar and @jdutil here since they commented on/opened that issue.

While I've been working on the Order model -- primarily with my work on #1743, but also with many, many other things -- I've become frustrated at the lack of organisation in this model. It just seems that methods have been thrown into there with no consideration of logical ordering at all. I'm not innocent of doing this myself, either.

The model itself is 600 lines long, and the related spec is about 1000 lines. In total, these are way too big to keep inside your head all in one group, and *extremely* difficult to navigate, even to people who've been working on Spree fulltime for 8 months now.

What I propose is that we split up the Order model into different components. All the order's address behaviour goes into `OrderComponents::Address`. All the line items behaviour goes into `OrderComponents::LineItems`. All the adjustments behaviour goes into `OrderComponents::Adjustments`. And so on, and so forth.

---

This is a work in progress. What I hope to separate out also is:

- Anything related to shipments
- Anything related to payments
- The tax logic into another module, or perhaps something better
- The updating logic into its own class, called `OrderUpdater`. That's mainly so it's easier to test, and it actually takes up a *huge* chunk of the `Order` model.