Note that there are some explanatory texts on larger screens.

plurals
  1. PODesign Technique: How to design a complex system for processing orders, products and units
    primarykey
    data
    text
    <p>Programming is fun: I learned that by trying out simple challenges, reading up some books and following some tutorials. I am able to grasp the concepts of writing with OO (I do so in Ruby), and write a bit of code myself. What bugs me though is that I feel I'm re-inventing the wheel: I haven't followed an education or found a book (a free one that is) that explains me the why's instead of the how's, and I've learned from the A-team that it is the plan that makes it come together. So, armed with my nuby Ruby skills, I decided I wanted to program a virtual store. I figured out the following:</p> <p>My virtual Store will have:</p> <ul> <li>Products and Services</li> <li>Inventories</li> <li>Orders and Shipping</li> <li>Customers</li> </ul> <p>Now this isn't complex at all. With the help of some cool tools (CMapTools), I drew out some concepts, but quickly enough (thanks to my inferior experience in designing), my design started to bite me. My very first product-line were virtual "laptops". So, I created a class (Ruby):</p> <pre><code>class Product attr_accessor :name, :price def initialize(name, price) @name = name @price = price end end </code></pre> <p>which can be instantiated by doing (IRb)</p> <pre><code>x = Product.new("Banana Pro", 250) </code></pre> <p>Because I want my virtual customers being able to purchase more than one product, or various configurations, I figured out I needed some kind of "Order" mechanism.</p> <pre><code>class Order def initialize(order_no) @order_no = order_no @line_items = [] end def add_product(myproduct) @line_items &lt;&lt; myproduct end def show_order() puts @order_no @line_items.each do |x| puts x.name.to_s + "\t" + x.price.to_s end end end </code></pre> <p>that can be instantiated by doing (IRb)</p> <pre><code> z = Order.new(1234) z.add_product(x) z.show_order </code></pre> <p>Splendid, I have now a very simple ordering system that allows me to add products to an order. But, here comes my real question.</p> <p>What if I have three models of my product (economy, business, showoff)? Or have my products be composed out of separate units (bigger screen, nicer keyboard, different OS)? Surely I could make them three separate products, or add complexity to my product class, but I am looking for are best practices to design a flexible product object that can be used in the real world, to facilitate a complex system.</p> <p>My apologies if my grammar and my spelling are with error, as english is not my first language and I took the time to check as far I could understand and translate properly! </p> <p>Thank you for your answers, comments and feedback!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload