Book of analogies

Learn Programming with real world examples

#amatterofcontext

#amatterofcontext

when you’re learning something new, connect it to something you already know

-- Alex Coleman, via Self-taught coders

Why Analogies?

  • Coding isn't easy
    • creativity, problem solving
  • New concepts, familiar mechanisms
  • Provides required context for learning
  • Programming -> Learn to think + new language
  • Work differently for everyone
    • contexts they're used to differ
    • distinct ways of thinking 

#amatterofcontext

Programs and Programming Languages

  • Recipes
  • A language to interact with the computer
    • computers don't know "english"
  • Compare to daily actions
    • react to traffic lights
    • how to eat something with cutlery

#amatterofcontext

Programming Languages

 

  • A language to interact with the computer
    • computers don't know "english"
    • has rules, grammar, sentences...

#amatterofcontext

Algorithms

  • Recipes (again)
  • Telephone list, looking for a number

#amatterofcontext

Variables

  • Boxes that can be filled with content

#amatterofcontext

Objects, associative arraws 

  • Key-value pairs (key is unique)
  • Just like a dictionary
    • ​terms are unique, othewise we couldn't look for them
    • actually called "dictionaries" in Python
  • Options for a videogame
    • imagine having different entries for the same option...
  • Any "object": what's its size, what does it do?... [3]

#amatterofcontext

Common Terms

  • Hotfix - like cleaning up a stain of boiling coffee with your hand and right after spilling it

#amatterofcontext

Hotfix

  • like cleaning up a stain of boiling coffee with your hand and right after spilling it
  • like repairing a running drone or car

#amatterofcontext

The Phone Store

(Kyle Simpson)

  • Price of phone is 99.99 (number)
  • Price of phone call if "free" (string/literal)
  • Does phone include a charger? (yes/no)

 

Number (maths), string (literal value), boolean (true/false)

#amatterofcontext

Types and values

Databases and files

#amatterofcontext

Client-server as people

HTTP Responses as dialog

#amatterofcontext

Meet James Client and John Server

Client-server as people

HTTP Responses as dialog

#amatterofcontext

200 - success

James Client

John Server

Hey John (at john.com), show me your right foot

Sure, here it is (shows right foot as if it were a web page) 

https://www.johnserver.com/rightfoot - 200

Client-server as people

HTTP Responses as dialog

#amatterofcontext

404 - not found

James Client

John Server

Hey John (at john.com), show me your right head

??? I know you're addressing me, but I don't understand what you're asking for!

https://www.johnserver.com/righthead - 404

Client-server as people

HTTP Responses as dialog

#amatterofcontext

500 - server error

James Client

John Server

Hey John (at john.com), show me your right foot

Ok here it... wait! Sorry, but I can't. I know what you're asking for, but something went wrong 

https://www.johnserver.com/rightfoot - 200 500

Frameworks

  • Framework = Foundation to Build a House
  • MVC - Building a LEGO Spaceship on demand
    • Models - ​Blocks
    • Controller - Builder (he's "in control")
    • View - Actual spaceship
    • Request - person who asked for spaceship

#amatterofcontext

Promises

  • Like phone calls
  • ​Can be answered or rejected
  • You can do other stuff while you wait

#amatterofcontext

APIs

REST vs GraphQL

online shop:

multiple products at once, single payment

 

 

#amatterofcontext

vending machine: one product and payment at a time

 

 

#amatterofcontext

Source: WDS 

If Web development was a house

  • HTML - structure (ex.: celing, walls, door)
  • CSS - aestetics (ex.: colors, texture)
  • Javascript - functionalities (ex.: opening doors)

Bibliografia

Made with Slides.com