-
Hello I am Samson
-
And today I would like to talk to you about writing code
-
Today you have all learned about programming
-
When people think about programing they generally think about comunicating with a computer
-
"It's all just 1s and 0s!" because just makes is simple...
-
Originally it was very important you talked to computers as efficiently as possible
-
As computers got faster it got easer to add levels of abstraction meaning you could start to write programs for people
-
Grace Hopper was the first person to write a compiler
-
Compilters translated human readable code into the machine code
-
As computers have gotten faster we have been able to have languages that are easier and easier for people to read
-
Ruby is a great example of this
-
But lets not kid ourselves
-
This [show scary method] is not that easy to read
-
Lets step back for a minute
-
We write programs so we can communicate with computers
-
But we write these programs to people to use
-
Programs are everywhere and need to be keeped up to date
-
Programming has also become social
-
And we are all standing on the shoulders of giants when we code
-
So even if you are writing code by yourself you are likely going to have to read other peoples code
-
And more than likely others will be reading your code
-
We have got to the point where it is way more important for your code to be for people than for it to be for machines
-
So how do we code for people?
-
Object Oriented programing helps us keep our code organised
-
When we write objects the goal is to make sure they only do 1 thing
-
When they try to do more than one thing
-
This happens [show scary code again]
-
A woman named Sandi Metz has proposed 4 rules to help with this
-
[show 4 rules: https://gist.github.com/henrik/4509394]
-
I am going to use 1 of them to make this scarry code
-
[highlight rule 2 "Your methods can be no longer than five lines of code."]
-
[scary code]
-
Into code that is much easier for people to read
-
[fake nice method]
-
[do a run though fixing scary method into nice readable small ones]
-
As you can see our code is not much easier to digest
-
It almost has a naritive when you read it
-
The next programmer that reads your code will likely thank you for your small methods. Maybe even give you a hug! #FridayHug
-
Thank you for your time
-
Talk inspired by Sandi Metz (@sandimetz), Katrina Owen (@kytrinyx), and Avdi Grimm (@avdi)
-
You can find me on Twitter @ootoovak, on Github at https://github.com/ootoovak and these slides on Speaker Deck here https://speakerdeck.com/ootoovak