1 Comment

Systems: Because You Can’t Count That Fast


Me trying to explain a global SAP ERP network to kids.

On Thursday, it was bring your daughters and sons to work day at Genentech. My little Marlowe is only 6 weeks old so I didn’t bring her, but my VP shot me a note Wednesday saying she was bringing her two boys, knew of some other kids who would be there, and wondered if I could give a 30 minute talk on systems. I responded, “sure.”

But what the heck do you tell kids ranging from 6-12 years old about your corporate ERP system? While fascinating, I doubt they’d care about the usual things that I work on and I wouldn’t dare show them PowerPoint slides. So what to do?

Thursday before lunch I slapped a Ruby script together (code below). It did 2 things: 1) let you decide how many plants were producing widgets, and 2) how fast they could produce. The first run looked like this:

How many plants are there? (max 6)
1
About how many seconds does it take a plant to make something?
5
Monitoring a network of 1 plants
STARTING P1
Plant 1: +3
Plant 1: +7
Plant 1: +3

Monitoring stopped
Plant 1 made 13

As the output slowly appeared I had them add up the widgets produced, which they did with ease. We clearly didn’t need systems … yet. Then we increased the number of plants and speed of production until we got to this scenario:

How many plants are there? (max 6)
6
About how many seconds does it take a plant to make something?
1
Monitoring a network of 6 plants
STARTING P1 |             |             |             |             |            
Plant 1: +8 |             |             |             |             |            
            | STARTING P2 |             |             |             |            
            | Plant 2: +9 |             |             |             |            
            |             | STARTING P3 |             |             |            
            |             | Plant 3: +3 |             |             |            
            |             |             | STARTING P4 |             |            
            |             |             | Plant 4: +5 |             |            
Plant 1: +8 |             |             |             |             |            
            |             |             |             | STARTING P5 |            
            |             |             |             | Plant 5: +4 |            
            | Plant 2: +5 |             |             |             |            
            |             |             |             |             | STARTING P6
            |             |             |             |             | Plant 6: +1
            |             | Plant 3: +7 |             |             |            
            |             |             | Plant 4: +3 |             |            
Plant 1: +9 |             |             |             |             |            
            |             |             |             | Plant 5: +1 |            
            |             |             |             |             | Plant 6: +8
            | Plant 2: +5 |             |             |             |            
            |             | Plant 3: +9 |             |             |            
            |             |             | Plant 4: +1 |             |            
            |             |             |             | Plant 5: +4 |            
Plant 1: +2 |             |             |             |             |            

Monitoring stopped
Plant 1 made 27
Plant 2 made 19
Plant 3 made 19
Plant 4 made 9
Plant 5 made 9
Plant 6 made 9

That’s a shortened example. In our exercise we let it run until each plant had made hundreds of widgets. Though they tried hard, they simply couldn’t keep up. At this point I stopped and asked them if it was now clear why we use systems and one kid answered beautifully: yeah, because you can’t count that fast. A week ago if you asked me, “why do you use SAP ERP,” I probably would have given you some long-winded, boring answer citing dollars, value, and other things that would put you to sleep. I like the simple version much better. Thanks kids.

If you’re curious, here’s the code. It’s not elegant, and could certainly be refactored, but I think it worked nicely to demonstrate why we use systems at work.

# Get some input about the plants in the network
puts "How many plants are there? (max 6)"
num_plants = gets.to_i
puts "About how many seconds does it take a plant to make something?"
seconds_to_make = gets.to_i
puts "Monitoring a network of #{num_plants} plants"

# Store plant inventory in an array
@@plants = Array.new(num_plants, 0)

# Wait for the user to hit enter and exit with inventory information
Thread.new do
  loop do
    s = gets.chomp
    puts "Monitoring stopped"
    count=0
    @@plants.each{|p| puts "Plant #{count+=1} made #{p}"}
    exit
  end
end

# Starts an independent plant thread and logs inventory
def start_plant(plant, sleep_for=seconds_to_make)
  Thread.new do
    loop do
      making = rand(9)+1
      front_pad = '            | '*plant
      back_pad = ' |            '*(5-plant-(6-@@plants.length))
      puts "#{front_pad}Plant #{plant+1}: +#{making}#{back_pad}"
      @@plants[plant] += making
      sleep sleep_for+(rand(0))
    end
  end
end

# Start N plant threads
1.upto(@@plants.length) do |p|
  plant = p-1
  front_pad = '            | '*plant
  back_pad = ' |            '*(5-plant-(6-@@plants.length))
  puts "#{front_pad}STARTING P#{plant+1}#{back_pad}"
  start_plant(plant, seconds_to_make)
  sleep 1
end

# Endless loop to allow other threads to run until interrupted
loop do; sleep 1; end

1 Comment

Comments are closed.