Delicious thoughts run through my mind when the phrase from scratch precedes anything that may possibly end up in my stomach. It immediately conjures up memories from my childhood days spent at my grandparent’s house. Visiting was always a little boring at first. They didn’t have the newest Nintendo game cartridges, they lived on Northern Minnesota’s Iron Range and enjoyed bringing me to rummage sales. As bad as that sounds to any child below the age of being-able-to-ride-a-go-cart-by-yourself, it would always end up better than it started when my grandma would bake homemade pie with garden-picked rhubarb. Within minutes of being put into the oven, the bitter and rustic, sweet smell would fill the house and tease our senses.
Dash of Data-Structures
This topic is one that may be scary to many people and frankly they should be scared. Data-structures are at the core of computational science and are not an easy topic, especially to those from an amateur background like mine. It wasn’t until I started my university computer science classes that I even started to contemplate diving into this strange and mysterious world of algorithms and information. However, the information provided here will hopefully act as a nightlight for anyone wishing to learn about the scary nocturnal information monsters living in closets and under beds.
Ample Amounts Of Array
Arrays are the butter of the computer science world, because they are literally in everything! What is an array exactly? Well, it is just an ordered list. That simple? Yep, but sometimes there are lists inside of lists and these are called multi-dimensional arrays.
This is like a grocery list minus the nagging. They are great for storing a collection of data that is loosely or strictly related.
So a quick breakdown shows us that we create a new array with the name “ingredientList”. Then we take the first slot in the array, index 0, and give it the string value “Butter”. Then we repeat this over and over again until we have a complete list. If you’re wondering why indexes start with 0, you’re not alone. I like to imagine it’s because no one wanted to hurt zero’s feelings by leaving it out.
This is kind of like Martha Stewart’s new recipe book with each page containing a new list. A great use for this is more advanced ordering of simple data into a categorization system. Look here to see how to make one:
Let’s break this down – anymore and we might have a death metal song. We see that in the first slot of the parent array we have inserted another array instead of just a string or number. This technique can be multiplied to the nth-dimension, but anything past the third dimension should be left up to Stephen Hawking, so try something else.
You’ll notice that nesting information is easy and still easy to read. This happens to be a list of recipe books with some information about them. It consists entirely of keys, the identifier to the left of the colon, and their values to the right. In order to access this information it is as easy as:
Wow, look at that! Nice, isn’t it? This is great for modeling information that should reflect real world logic.
Include Some Iteration
Iteration in example is reading over a recipe list and at each recipe doing something specific with that information, like deciding if you have it available or not. This is an invaluable tool for working with lists of information or collections.
Wrap With Recursion
When you see the word recursion, try to think of what happens when you face two mirrors toward each other. The light bounces back and forth between them and the mirrors get infinitely smaller. When we do this with data it allows us to create functions that call themselves within the definition – similar to Russian nesting dolls – but for this example we’ll say it’s like a cook book hidden within another cook book.
This can look scary at first, but if you read the step by step explanations it is really easy. Recursion can be used for many things, but most often it is used to process a collection with an unknown amount of elements. This is the basic idea behind recursion. It comes in peace.
Callbacks are the same as when you need to make pie, but before you can include the dough in the process of making it, you must first complete the process of making the dough. We do this with functions as well. Often we use the return value of one function to give another function context or variables to work with.
I can almost hear the locks in your brain clicking open as you realize what you can do with this recipe.
Eat All The Elements
Once you have this object there are limitless things you can do, but I am not going to go over each and every one so go ahead and search online for more information about the DOM.
Mmm … Pie