Second Lesson, Break it down.
"We can dance if we want to, We can leave your friends behind"
*Looks up*
Wha!? No I wasn't dancing the safety dance. That would just be stupid!
Ok here's the second lesson, this and the next few lesions will focus on how to take a system you want to script and
break it down into smaller and smaller pieces that until you have something that you can actually script.
These lesions are intended to teach
Programming not just Ruby, in fact when we do get down to the ruby side of things
I'll only brush briefly on the concepts you need. As such it is a
VERY good idea to
start reading a simple ruby tutorial in order to learn the syntax.
Programming is a
skill, one that allows a human to instruct computers to do tasks. Ruby is a
language, a
tool by which a person can program. But the fact of the matter is that when learning how to program it is best to realize that, just because one knows the syntax and grammar of a language DOSE NOT mean they can program in it.
As I said these next few lessons will focus on breaking down the system we created so that it can be scripted. That means be will be working with
layers of abstraction Read this to learn more.
Abstraction -
http://en.wikipedia.org/wiki/Abstraction_(computer_science)Now that you know what I mean by abstraction I'll explain the process.
If you think of the entire system as a whole then you're thinking of the
highest level of abstraction that the system has.
Going one 1 layer in abstraction down you'll find that the system is made of three or four
smaller pieces. These pieces take in data, compare it to data the pieces keep internally and spit out some new data.
Going down 1 level further you'll find that those three or four smaller pieces are in turn made of other pieces that once again take in data, do something with it, and then return new data. You can keep going like this until you find that you have reached the
lowest level of abstraction in our system. This level is made of only the base statements that make up Ruby: assignments, operators, method calls to the standard library, ect.
In truth you could keep going lower from those base statements into the C language, which ruby is built on, and from there even lower into byte code. But that would be pointless. The reason Ruby is so nice to learn with is because all that complicated stuff, like memory management and manipulation, has been abstracted away so that we don't have to deal with it.
So, we are going to break down the system into smaller pieces, going 1 level of abstraction deeper each time.
You're assignment is to write down a model of the system and submit it by posting it inside a spoiler, that way other student don't have to see your work if they don't want to. I encourage you to not look at other's work you don't learn anything that way, at least not with this type of thing. Your trying to grasp a complex concept here, not memorize your multiplication tables
.
I'll give you a little help to get you started.
Start by writing down everything the system dose, than break those actions out, start by grouping them together if they are all related think of these groups of actions as an object, a little machine that dose all these actions. then break them apart further. Stop when you think the lowest objects in your modal could be scripted in 3-20 lines of code (you don't have to know how, just as long as you think the action is simple enough to be expressed in terms of the simple statements that are Ruby).
Here's a video I mad that might explain the concept better.
http://www.youtube.com/watch?v=s8HNrlvRCD8Each of you submit your own modal.
IN SIDE A SPOLIER PLEASE (use this bbcode [spoiler][/spoiler] which results in this )