Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Los diez mandamientos del programador ágil

Los diez mandamientos del programador ágil

Keynote presentado en el Reginal ScrumGathering Lima 2016 #rsgpe2016

Emilio Gutter

April 16, 2016
Tweet

More Decks by Emilio Gutter

Other Decks in Programming

Transcript

  1. YO SOY EMILIO UN PROGRAMADOR ÁGIL programador +17 yrs co-fundador

    de 10Pines miembro fundador de la comunidad Agiles co-chair de la conferencia ágiles 2012 marido, padre Y cervecero casero
  2. public List selectPending(List registrations) { List pending = new ArrayList();

    for (Registration registration: registrations) { if (!registration.isPaid()) { pending.add(registration); } } return pending; }
  3. class SessionsController < ApplicationController def create @session = Session.new(session_params) if

    @session.save redirect_to my_sessions_path, notice: 'Session created successfully' else render :new end end end
  4. class Program def find_by_author(author) sessions = Session.where(author: author, approved: true)

    if sessions.empty? # do something else # do something end end end
  5. public class AttendeePresenter {
 
 private Attendee attendee;
 
 public

    AttendeePresenter(Attendee attendee) {
 this.attendee = attendee;
 }
 
 public String phoneNumber() {
 if (attendee.getAddress() != null) { Address address = attendee.getAddress();
 if (address.getPhoneNumber() != null) {
 return address.getPhoneNumber();
 } else {
 return "Phone number is not available";
 }
 }
 return "Address is not available";
 }
 }
  6. public class Attendee {
 
 public Attendee(Address address) {
 if

    (address == null)
 throw new IllegalArgumentException(“…”);
 this.address = address;
 }
 
 public Address getAddress() {
 if (address == null) return new UnknownAddress();
 return address;
 }
 
 public String getPhoneNumber() {
 return Optional.ofNullable(address) .map(Address::getPhoneNumber)
 .orElse("Phone number is not available");
 }
 
 }
  7. class BankAccount def process a_transaction if a_transaction.type == :purchase #

    charge transaction fee else # assume refund end end end
  8. class BankAccount def process a_transaction a_transaction.process self end def process_purchase

    a_transaction # charge transaction fee end def process_refund a_transaction # refund transaction fee end end
  9. class Purchase < Transaction def process a_payment_method a_payment_method.process_purchase self end

    end class Refund < Transaction def process a_payment_method a_payment_method.process_refund self end end
  10. require 'spec_helper' describe Registration do setup do a_conference = Conference.new("ScrumGathering")

    a_registration = Registration.new a_ticket_store = double("TicketStore") end it ‘tickets available' do expect(a_ticket_store).to receive(:tickets_available?). with(a_conference).and_return(true) expect(a_ticket_store).to receive(:remove).with(a_conference) a_registration.process(a_ticket_store) expect(a_registration.confirmed?).to eq(true) end it ‘run out of tickets' do expect(a_ticket_store).to receive(:tickets_available?). with(a_conference).and_return(false) a_registration.process(a_ticket_store) expect(a_registration.confirmed?).to eq(false) end end
  11. class Speaker < ActiveRecord::Base devise :omniauthable, :omniauth_providers => [:facebook] def

    approve_session(session) # do something SessionMailer.approve(speaker: self, session: session).deliver end end
  12. VI. NO TOMARÁS A TUS TESTS EN VANO VII. RECUERDA

    REFACTORIZAR CADA DÍA VII. AMARÁS HACER PAIR PROGRAMMING CON TUS COMPAÑEROS