# Learning Programming: Functions, Inputs, Syntax and Outputs

In our previous lesson, we started using spreadsheets (Excel or Google Docs Spreadsheets) to start learning some common ideas that apply to all programs. We wrote down a simple formula to calculate the sum of two numbers: =sum(A1, B1)

So what does this tell us about programming? The first thing is to notice that we used a function to compute the sum.

# Learning Programming From the Ground Up

How do you learn programming, if you don’t know anything about programming at all? I’ve been very curious about this problem, especially in recent months, as I hear stories of  the digital divide, and the growing gap between STEM graduates and jobs in the US. There is also the question of digital equity – if someone has already gone past school and college without exposure to the basics of programming, what are their options for catching up?

I spent about six years and change studying for two degrees in Computer Science. I learned how to program before I joined college. But a lot has changed since I went to college, and while it might have been expensive and difficult to introduce oneself to these concepts back then, today there are a host of services and tools that make it much easier and faster to come up to speed on how programming works.

This blog post is the first in a series that focus on these services and tools, to teach someone who isn’t a programmer, to learn how to teach themselves the skills. These posts will assume not that you are a programmer, but that you’re willing to follow the exercises, search for answers on the Internet, and be creative in attempting to find the answers.

# Ruby Metaclasses Part II: Why @@ Is Not Really a “Class Variable”

We are on our way to understanding why Ruby has metaclasses. The short answer – TL;DR – is that metaclasses are necessary because Ruby implements class inheritance in a “flat way” – all classes derive from one class called (very plainly), Class. Class can’t hold all the methods that need to be inherited by the various classes in your program, so you need each class to have a special parent class – which is what the metaclass is.

Well, let’s get back to understanding all the details of class inheritance first. In our last lesson, we got to how we create “class instance variables.” Let us now figure out what the @@ notation is all about.

# Subclassing Models In Rails Is Called Single Table Inheritance

There’s one thing I’m beginning to not like about the Rails framework a little, and that’s the penchant that it has for making up names for concepts that already exist in programming languages.

If you have been programming in object-oriented frameworks for a while, you’d be surprised to know that Rails likes to call it “single table inheritance.” Why not just call it “class hierarchy” or maybe even “model hierarchy”? Continue reading “Subclassing Models In Rails Is Called Single Table Inheritance”

# Ruby Metaclasses: What Are They Good For? Part I

I’ve been playing around with Ruby for a while now, and I know that you can create meta-classes, but why this is a feature designed into the programming language hasn’t been very clear to me. Until today, when I found a use-case that really brought it home to me.

A critical part of understanding the reasoning behind having meta-classes was actually when I took some time to understand what the @ and @@ notations really do. A lot of tutorials and descriptions will say that this is the syntax for defining, respectively, “instance variables” and “class variables.” This isn’t entirely true.

# Rails Adventure du Jour: Testing!

So I’ve started testing my code now, and delved a bit into the world of RSpec, Capybara and BDD.

This will take a while to figure out but here are two things I learned that aren’t really described anywhere in the most popular tutorials on Rails testing:

1. All your spec files should end in _spec.rb
2. It’s good to know what matchers and helpers to include – config.include Devise::TestHelpers, type: :controller inside the block of RSpec.config and require ‘cancan/matchers’ are two good ones to add, if you have authentication and authorization going on with your app.

# Technical Adventure du Jour: Setting Up LAMP on Ubuntu From Scratch

So yesterday I decided that I was going to distract myself a bit by moving all my websites to a Digital Ocean “droplet” (virtual machine – why does everyone need to find a cute name for the same idea? Get off my lawn, you stupid kids!)

I’ve done a Ubuntu setup of the LAMP stack a few times now, but everytime I forget the little gotchas, so in case someone else out there is doing this, here are a few tips: