- The next one to prove the first is wrong
- Choose a name inline with the concept in the domain.
- Good OO code names concepts, not worried about implementation
- Terseness is cleverness (not goodness), stop picking on each other for being simple.
- Smallest change you can make to prove the last test insuficient.
- Solve the easy problems first, then maybe the hard ones become easy.
- DRY is good, but sometimes duplication makes sense, if it passes the inebriation test, check it in and walk away
- Open/Close Add new features without adding new code
- lean on the green
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/tasks/db.rake | |
namespace :db do | |
desc "Dumps the database to db/APP_NAME.dump" | |
task :dump => :environment do | |
cmd = nil | |
with_config do |app, host, db, user| | |
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
end | |
puts cmd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
class Heartbeat | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
if env['PATH_INFO'] == "/pulse" | |
@messages = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe TodosController, :type => :controller do | |
describe "GET #index" do | |
#describe "POST #create" do | |
#describe "GET #show" do | |
#describe "PATCH #update" do (or PUT #update) | |
#describe "DELETE #destroy" do | |
#describe "GET #new" do |
Code smells, get really good at code smell (brown bag)
All you have to know is the codes smells
make a million new things > mutate objects
Forwardable (delegation)
Don't go on a virtical tangent, instead tiptoe away and finish the horizontal refactor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
╔═════════════════╗ ┌─────┐ ╔═══════════════════╗ | |
║ ║ │ YES │ ║ Make the intended ║ | |
───────▶║ Is it open? ╠──┴─────┴──────▶║ change. ║ | |
▲ ║ ║ ▲ ║ ║ | |
│ ╚═════════╦═══════╝ │ ╚═══════════════════╝ | |
│ │ │ | |
│ ┌────┤ │ | |
│ │ NO │ │ | |
│ └────┤ │ | |
│ │ │ |
If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8
To use the new phx.new
project generator, you can install the archive with the following command:
$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs
:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.configure do |config| | |
example_sql_counts = Hash.new(0) | |
config.around(:example) do |procsy| | |
sql_count = 0 | |
callback = ->(*args) { sql_count +=1 } | |
ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do | |
procsy.call | |
end |