Makers Pre-Course — Week 3

Day 11 — Monday 9th November

Feeling at beginning of day: relaxed

  • Writing your own methods: Methods are reusable procedures. As a variable is a named object, so a method is a named procedure.
  • Calling methods on the main object can be done without the dot syntax.
  • When we send an object a message the object invokes a method using that message. Then the object carries out a procedure. Finally the object returns something back to whatever sent the message.
  • To designate what the return value should be from a method, use the return keyword.
  • An empty method has an implicit ‘return nil’ within it.
  • Method parameters are temporary names for objects provided as arguments.
  • Abstraction: abstraction makes code easier to work with but less easy to understand what’s going on beneath the hood.
  • Picking the right level of abstraction is very difficult.
  • Abstraction rules of thumb; 1) Can you name your method in a simple way, without using the word, ‘and’? Does it do one thing and nothing more? 2) Can you name your method after what it returns instead of what it does?

Day 12 — Tuesday 10th November

Feeling at beginning of day: determined

  • Imperative Programming: telling the computer how to do something
  • Declarative Programming: telling the computer what to do.
  • Telling an object what we want might look like; “average these scores”. This is called declarative programming.
  • As programmers we try to abstract our work to a declarative style wherever possible. One route to doing so is: Object oriented programming:
  • Declaring your own classes: new classes = new gods.
  • Ruby has a class called class. It is the god of all classes. If you use the class keyword on an undefined class it will automatically create it.
  • Object Properties: Object state: integer knows about value, string knows about text. Infact a string’s internal characteristics are referred to as properties of the string.
  • Instance Variable: is resident in the class instance. Methods that set an object state using instance variables are called setters.
  • Mutating Object State: a method can be defined which amends the object state.
  • Using initialize to set up instances: Ruby automatically defines the initialize method even if you don’t write it.
  • Different Kinds of Variables: instance variables include an @ sign at the beginning. you also have local variables, and method variables. The difference is broadly which objects can see these variables.
  • Regular variables are normally referred to as local variables. Local variables are available to anything that wants it.
  • The area of a programme in which the variable can be read is called the scope.
  • Def and Class are known as scope gates. Ruby files also act as scope gates.

Day 13 — Wednesday 11th November

Feeling at beginning of day: optimistic

  • an array in programming is an indexed collection of related items.
  • indexed collection means things are ordered.
  • Can call .first or .last on an array as well. Useful if you don’t know the length.
  • You can .sort an array
  • symbols are not variables, so you can’t assign anything to a symbol directly.
  • however, you can use a symbol as a value.
  • symbols are immutable, which means they are memory efficient, as the exact amount of memory is allocated rather than a flexible amount, as per strings.
  • alternative hash syntax with symbols. you could write: capitals = { :france = “Paris”, :germany = “Berlin” } or a nice bit of syntactic sugar: capitals = { france: “Paris”, germany: “Berlin”). ‘france:’ and ‘germany:’ are both still symbols despite the colon being at the end.

Day 14 — Thursday 12th November

Feeling at beginning of day: bit nervous about pairing.

  • Pair programming is the process whereby two people actively collaborate on developing code.
  • Key component of pair programming is regular driver/navigator switching.
  • Swap every 15mins.
  • Take occasional breaks every 90mins.
  • It’s possible to collaborate directly with another developer on the same GitHub repository, from respective local repositories.
  • One developer sets up local and remote repos.
  • Then invites the other developer to collaborate on GitHub.
  • Once the invite accepted, the other developer can clone the original GitHub repo onto their local directory.
  • Then updates can be committed by both developers directly.
  • TDD = Test Driven Development
  • Process of writing tests first, that should then be resolved to pass through code development.
  • The code is developed to pass the tests.
  • The tests need to be a representation of the specification.
  • Rspec is a ruby library, that supports TDD.
  • The software is a testing framework, that enables tests to be written, and then evaluated against the prescribed code base.
  • Very Powerful.

Day 15 — Friday 13th November

Feeling at start of day: buoyant



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store