- Avoid imperative conditional logic
- If you can do it with an enumerator, then just do it
- Keep 90% of the overall methods idempotent
- Wrap small sections of imperative shell around composite idempotent methods
- Think in terms of behaviors and values, not objects and messages
- Identify and classify data clumps (primitives that do not work as sub data)
require 'io/console' | |
# Adventure game in MatzLISP :) | |
COMMANDS = %w{quit} | |
DRAGON = File.read("dragon.txt") | |
get_input = -> { STDIN.gets.chomp } | |
prompt_user = ->(msg) { STDOUT.puts msg } |
* Keep methods rediculously short | |
* Methods should do 1 thing | |
* Be idempotent when at all possible | |
* Leave objects open to extension, but closed to modification | |
* Don't modify objects unless constrained by memory operations | |
* Wrap Network and Disk and Database calls with encapsulation | |
* Dont mock what you dont own | |
* Write real unit tests, test inside the boundaries | |
* Write common path itegration tests, test the boundaries themselves |
TERRIBLE EXPERIENCE!
I moved back to Vallarta in spring of 2014. The first apartment these guys rented to my finance and I turned out to be a crazy lady who accused us of having cats we do not have and kicking us out at 2am the first night we arrived.
After dragging all our belongings down over 100 steps and into a taxi and to a hotel, it was a night of hell.
The next day they moved us to a new apartment. We bought a washer machine and a very nice hammock. The building was shared by other short term vistalegre rental customers. In 3 months we had three gay old men (1 at a time) beneath us in the lower apartment.
Their smoke was constantly in my apartment, there was no separate meter on the gas so I shelled out all the gas money after it repeatedly ran out. Vistalegre did little to reimburse me for the other tenants half.
shout =->(name) { "HELLO #{name.upcase}!" } | |
def greet(name, greeter) | |
greeter.call(name) | |
end | |
puts greet("Robert", shout) #=> HELLO ROBERT! |
class User < ActiveRecord::Base | |
def display_name | |
full_name || email_designator || "I haz no name nor email!" | |
end | |
def email_designator | |
return nil if email.blank? | |
@email_designator = email.split("@")[0] | |
end |