“And what is the use of a book,” thought Alice, “without pictures or conversation?”

Frances Maxwell
A Parent’s Adventures in Codeland
4 min readOct 18, 2016

At last we’re starting to see our efforts deployed onto the web!

So we’ve just started week 4 of Makers Academy and for the last week or so, we’ve been working on web applications. Woohoo! This is exciting because up until now, our programs have only been accessible via the command line, which isn’t massively sexy to look at (actually it kind of is if you’ve badassified your terminal — check out mine below).

This is a ‘Battle’ game I created last week. Let’s face it, it’d be a LOT more fun with graphics!

Web apps = fun for EVERYONE.

So today, my pair partner and I deployed a web app (albeit a very limited one) to Heroku - a cloud hosting service for apps - which means that YOU, dear reader, can access it! No, I’m not posting the link as it’s barely functioning right now, but I might do later if it turns out all right.

However this is super exciting, because not only is it available to you, but this web app is also database-driven, using a database called PostgreSQL (I have no idea how to pronounce that) and an object-relational mapping tool called DataMapper (more about this beautiful amazingness in a bit).

I’ve got the whole programming world in my hands.

I am truly geeking out here because at last, a lot of the concepts I have been familiar with for years, like object-oriented programming, SQL (the language you use to interact with databases) and database structures (tables, columns etc) are beginning to make sense as a whole.

This was me today.

For example, in Ruby, we create objects using classes (you create a ‘Student’ class, from which you can create ‘instances’ of that class, i.e. students). And in your database, you’d have a corresponding ‘Students’ table which would contain rows (instances) of students.

“WHY IS THIS BEAUTIFUL?”, I hear you ask. Because, you BABE, that means (if I’m not mistaken) that you don’t have to spend ages creating mental entity-relationship diagrams to design your database structure upfront (these diagrams gave me the fear at university — see below). “HOW SO?”, you ask. Because of the beauty of the way we’ve been taught to program!

An entity-relationship diagram. Pass me the gin.

So how have we been taught to program?

Basically — don’t think about the whole thing and get overwhelmed. Underwhelm yourself by starting small!

Nothing is particularly hard if you divide it into small jobs — Henry Ford

The process we’ve been following is something like this:

  1. Take your user stories, e.g. As a student, I want to register for a class so that I am enrolled in it. [obvs there’ll be loads more]
  2. Look for the nouns (objects) and verbs (messages) and create a domain model from that, e.g. ‘Student’ (object) and ‘register’ (message) — even if it’s shit and you’re not sure what a domain model is. The mere exercise gets you thinking about objects and how they communicate.
  3. From the domain model, choose the simplest, most basic feature to implement, write a failing feature test (this will help you think about how a user will interact with it), a failing unit test (to test individual bits of code), and then pass the tests by constructing your classes and methods.

You do this iteratively for each feature until you’ve built the ‘engine’ (or model) that fulfils the user stories (the requirements) of your program.

HTTP doesn’t lie.

What’s so lovely about this is that that once you’ve got it all working (and it’s a lot easier than I’m making it sound), and have refactored your classes to ensure they have a single responsibility (not so easy), correct me if I’m wrong but you’ve pretty much got your database structure and relationships sorted! This is so incredible to me!

After this, you can even start thinking about your user interface (quelle horreur, my UX friends gasp — you think about the interface last?!)

[Huge caveat for anyone looking to learn from this: I may be wrong about this approach to database design as I literally just discovered this relationship between classes and tables this afternoon, but it really felt like an AHA moment for me. I’ll confirm either way later on!]

Do you remember how amazing this video was?

Object-relationship mapping = AMAZEBALLS.

So it’s not quite up there with condensed milk in a tube, but this has been my other major discovery of the week.

Belinda Carlisle was right.

Get this. You don’t have to manually write the SQL to interact with your database, i.e. to Create, Read, Update or Delete your data (what a CRUDdy acronym). Instead, you can use a beautiful go-between called an object-relational mapper (like DataMapper)! It’s so pretty and MAGICAL.

I haven’t got time to go into more detail now (sorry, I know you were dying to hear more) as I’m lacking in sleep, so I will love you and leave you for now.

Thanks a MILLION for reading!

Frances x

--

--