Skip to content

Instantly share code, notes, and snippets.

View amuhle's full-sized avatar

Alvaro Muhlethaler amuhle

View GitHub Profile

Keybase proof

I hereby claim:

  • I am amuhle on github.
  • I am amuhlethaler (https://keybase.io/amuhlethaler) on keybase.
  • I have a public key ASA1n5UTyaOSodz--k1xNJ_DTDHjjcOUVH9NypPNEhBn_go

To claim this, I am signing this object:

@amuhle
amuhle / poodir-notes.md
Created February 13, 2019 11:28 — forked from speric/poodir-notes.md
Notes From "Practical Object-Oriented Design In Ruby" by Sandi Metz

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.
require 'minitest/autorun'
class ArrayUtil
attr_reader :array
def initialize(array)
@array = array
end
def super_flatten
@result = []
{
"id": 1880,
"first_name": "Jordi",
"last_name": "Alba",
"email": "[email protected]",
"token": "BQ6A-Q353",
"status": {
"name": "results_ready",
"label": "Results Ready"
},
require 'active_record'
require 'mysql2'
require 'minitest/autorun'
require 'logger'
puts "ActiveRecord: #{ActiveRecord::VERSION::STRING}"
ActiveRecord::Base.establish_connection(adapter: "mysql2", host: "localhost", database: "test")
ActiveRecord::Base.logger = Logger.new(STDOUT)
class Author < ActiveRecord::Base