Linear code is more readable
The code in the red is imperative, with implicit state all over the place. I would argue that it&#x27;s not linear, you have to keep all those mutable values and state transitions in your head as you read what&#x27;s happening from top to bottom.<p>It&#x27;s not extensible, It&#x27;s not composable, It&#x27;s hard to test, and frankly, it&#x27;s complicated and complex for no other reason than a particular type of engineer thinks its easier to read, because they feel all programming should be imperative.<p>Don&#x27;t get me wrong, there&#x27;s a time and a place for this style of programming. (Manual memory management, algorithmic design that maximizes speed or memory usage, or even taking a bunch of services and dictating the order in which they are supposed to be executed.)<p>For business logic, especially the type thats supposed to model &quot;the world,&quot; this is terrible code.<p>How is the bottom, not better code?<p><pre><code>    type Oven struct {
        Temp int
    }

    type Box struct {
        &#x2F;&#x2F; Box properties
    }

    type Pizza struct {
        Base    string
        Sauce   string
        Cheese  string
        Toppings []string
        Baked   bool
        Boxed   bool
        Sliced  bool
        Ready   bool
    }

    type Order struct {
        Size string
        Sauce string
        Kind string
    }

    func preparePizza(order *Order) *Pizza {
        toppings := map[string][]string{
            &quot;Veg&quot;:  []string{&quot;Tomato&quot;, &quot;Bell Pepper&quot;},
            &quot;Meat&quot;: []string{&quot;Pepperoni&quot;, &quot;Sausage&quot;},
        }
        return &amp;Pizza{
            Base:     order.Size,
            Sauce:    order.Sauce,
            Cheese:   &quot;Mozzarella&quot;,
            Toppings: toppings[order.Kind],
        }
    }

    func bakePizza(oven *Oven, pizza *Pizza, cookingTemp int,    checkOvenInterval int) *Pizza {
        &#x2F;&#x2F; Simulate oven heating
        for oven.Temp &lt; cookingTemp {
            time.Sleep(time.Duration(checkOvenInterval) * time.Millisecond)
            oven.Temp += 10 &#x2F;&#x2F; Simulate oven heating
        }
        pizza.Baked = true
        return pizza
    }

    func boxPizza(pizza *Pizza, order *Order) *Pizza {
        box := &amp;Box{}
        pizza.Boxed = true &#x2F;&#x2F; Simulate putting pizza in box
        pizza.Sliced = true &#x2F;&#x2F; Simulate slicing pizza
        pizza.Ready = true  &#x2F;&#x2F; Simulate closing box
        return pizza
    }
    
    &#x2F;&#x2F; I just need to really understand this imperative part
    &#x2F;&#x2F; this is the meat and potatoes
    func createPizza(order *Order, oven *Oven, cookingTemp int, checkOvenInterval int) *Pizza {
        pizza := preparePizza(order)
        pizza = bakePizza(oven, pizza, cookingTemp,  checkOvenInterval)
        pizza = boxPizza(pizza, order)
        return pizza
    }</code></pre>