The Automated Store – Chart

In previous posts, I wrote about the creation of an automated store machine in the 1900′s. In the chart below, I have jumped ahead to when the actual machine is first installed. I think this chart can help people get an overview of certain concepts by seeing them in physical form.  I created the rough sketch below with a pencil, but when I get better drawing software I will be able to create a digital version, which will be updated with color and more.

The Web Framework from a Century Ago

Machine Overview
While initially the main purpose of the machine was so the store owner could track inventory, many new features were added. This picture focuses on customers who which to view the inventory/catalog information themselves.
The customers enter their information by punching holes into a “HTTP” card they are viewing. This card then goes into the Router which cuts it up and sends it to the appropriate controller. For example, if a user asked to views product #43, the router will pass “43″ to the Product Controller’s viewing arm.
The controller will then send this information to the Active Record Player, which will send back the relevant data, as seen in the previous post. In this case, it would send back a copy of product card #43. The controller’s Action View will then take over and combine the data with the relevant templates to create a page. This will involve cutting up the data-card and inserting the information into the correct location on the “view product” catalog page. The page will then be combined with some general headers and some styling layers from the assets box, and then the whole thing will be pressed into a single page and sent back to the customer.

The Automated Store – Accessing Data

This is part two in a series about a mad engineer and the machine-framework he created in the early 1900′s. Any resemblance to modern frameworks, living or dead, is purely coincidental. 

In the first post of this series, the store owner, Jim Blackford, outlined the basic requirement he would need for Version 1 of the Automated Store Machine. We’ll quickly review his requirements:

Blackford: Well, I want to keep track of my inventory. So I guess it should let me create inventory records and store them well. The I should be able to access them at any time to read them, update them, or delete them. And it should keep track of how much inventory I have, and let me modify that when I get a new delivery or sell an item.

Dr. Hanson: Crud, that’s a lot of work. But me and my assistant can get started on building that machine. We’ll keep you posted on our progress…

Part II - In The Hanson Basement.
Dr. Hanson discusses his plans with his assistant, Dave Kemp. 

Dave: What up doc?

Hanson: We have a new project. I met with Mr. Blackford, and he needs a machine to track his inventory.

Dave: An inventory machine? How will that help you achieve world domination?

Hanson: This machine will not just be focused on tracking inventory. For Mr. Blackford’s own sake, we will need to make it extendible so we can add new components to help with his store. But my plan for this machine is greater than that. Once we complete this machine, we will look at the principles of its design and use them to build other machines for all sorts of purposes. Ba-Ha-Ha!

David: How will you do that?

Hanson: We will need to work out the details. But we will use solid engineering patterns that will then be able to used when building other machines. After all, what is the purpose of any calculating tabulating machine? It needs to store and retrieve data in an easy fashion, and perform simple operations on the data. Once we have the right design worked out, everyone will want our machine! They will no longer need to have their own Personal Hodgepodge of Pasta built from scratch, they will be able to start out with solid architecture.

Construction Begins – Accessing data (rough version)

rails-toon-1

The Automated Store – The Plan

This is a the first post in a story about a mad engineer and the machine-framework he created in the early 1900′s. Any resemblance to modern frameworks, living or dead, is purely coincidental. 

Dr. Victor Hanson was a brilliant mathematician and engineer, though a tad crazy. He had invented a machine that could perform various calculations, but it had not sold well, and anyways he wanted to create something more ambitious. He decided to take out an ad in a newspaper to see if anyone needed his services:

newspaper-ad

Jim Blackford had been running his store without too much problems for some time, but he was getting a bit bored dealing with the same tasks every day.  He wished he had some way to automate some of these processes. One day, when reading the paper, he noted an interesting ad…

A week later, in a restaurant in New York:

Blackford: Dr. Hanson, I presume?

Hanson: Yes, nice to meet you. I can now tell you about my automated machine services. I built machines that can calculate and tabulate numbers, but I’m thinking of branching out into other areas. What kind of machine do you need?

Blackford: I’m tired of dealing with the same manual tasks while running my store. It would be nice if a machine could just take over various operations for me. Though I’m not sure how that would be possible considering our pre-digital age and all.

Hanson: Nothing to worry about, I cans create analogue machines.  Now what specific requirements do you need in your machine?

Blackford: Well it would be nice if I could receive some automated help  to keep track of all inventory, process transactions, display brochures to customers, and maybe hand them products from higher shelves too.

Hanson: Wo, not so fast! Let’s focus on the most essential features you need first and later we can iterate on that. What is the most basic important thing you are looking for when shopping for automated store-running machines?

Blackford: I guess some way to keep track of all my inventory.

Hanson: OK, so let’s focus on that. What exactly do you want the machine to do?

Blackford: Well, I want to keep track of my inventory. So I guess it should let me create inventory records and store them well. The I should be able to access them at any time to read them, update them, or delete them. And it should keep track of how much inventory I have, and let me modify that when I get a new delivery or sell an item.

Hanson: Crud, that’s a lot of work. But me and my assistant can get started on building that machine. We’ll keep you posted on our progress…

Stay tuned for the next post where Dr. Hanson builds a first version of his machine. You can follow me on Twitter or RSS

Learning Ruby and Rails

Note: This post on Ruby and Rails is the final one in a series on Learning How to Program. Previous posts were: Picking a Language, General Tips, Java and Python, and Web: HTML, Javascript, PHP

Say you don’t want to edit old PHP scripts, but instead want to create your own new web application. A good choice would be Ruby on Rails, the ‘cool’ framework for creating websites. It contains various tools and elements that are common to most web applications so you do not need to re-create them from scratch in your own website.   For example, most web apps have forms that take user data and place them in a database. Ruby on Rails lets you create such forms quickly and securely. Rails is written in Ruby, so to code with Rails, you will need to know some Ruby. While you don’t actually have to spend that much time coding with Ruby before starting Rails, I think it makes more sense for a beginner to get comfortable with programming basics before taking on a complex web framework.

Ruby
As always, it’s good to jump right in with an interactive tutorial, which there is no lack of in Ruby. You can spend a few minutes on TryRuby and then look at Codecademy or go through slightly more advanced material on RubyMonk, which has 1 free course and additional courses for $10/month. If you like videos, you can pay $25/month and get access to CodeSchool’s courses, including RubyBits.

You should have a book also though. Learn to Program is geared at teaching programming concepts to beginners, and they aso have a more recent paid edition. The Humble Little Ruby Book is good for learning Ruby, though if you prefer more attitude and random cartoons, there’s the famous Why’s Poigant Guide to Ruby. If you have more experience and really want to get experienced at Ruby, there’s the Pickaxe Guide.

If you want to download something to teach kids Ruby, there’s Hackety-Hack, and if they’re just interested in games, there’s Ruby4Kids.

Ruby on Rails
After learning the basics of programming and Ruby, you can start learning Rails, which also has interactive tutorials. CodeLearn recently launched to let people learn Rails by trying out things from within their browser. If you like learning by watching zombie videos, check out CodeScool’s famous RailsForZombies. You can then signup to CodeSchool and get access to the sequel.

The ‘official’ free text to learn Rails is the Ruby on Rails Tutorial, which goes through all the details on how you would create a Twitter-clone, from getting things installed to version control, from “rails-flavored” ruby to nice CSS styles, and of course, all the fundamentals of Ruby on Rails.
The book places a strong strong emphasis on writing test code, which is code that tests out your main code to ensure it does what you want it to. It follows the TDD and BDD processes, which means you write the tests before you write your actual program’s code. Sometimes you will spend more time writing the tests than actually writing the rails code, but this way you will know your software always works. You can always skips some of the test-parts if you feel its too much.
The issue with a step-by-step tutorial book is that you need to make sure you think about how to do things, and not just copy what the book says. It might be helpful to try to figure out what to do before looking at the code in the book, though that won’t always be possible.

If you have a little experience, you might like Agile Web Development with Rails, which goes through how to create a shopping-cart application in part 1, and contains a rails reference in part 2. To learn how to do specific things, you can watch the screencasts on Railscasts. There’s also the official Rails Guides, which cover various aspects of Rails.

Of course, to actually learn Rails or programming well, you need to work on your own projects. As mentioned, you should find someone to help you work through a project. If you have a couple months, you could consider signing up at one of the Rails bootcamps that sprung up recently. Devbootcamp pioneered the bootcamp approach in SF, AppAcademy  claims they’ll only charge you if you get a job, Starter League is well-established in Chicago and Flatiron School recently started in NY. They charge $8k – 12k, but many give partial refunds if you take a job with one of the companies they’re connected with.

With all these resources, it’s easy to try out programing and then pursue it further if you like it.