Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
¿Dónde están mis interfaces?
Search
Jano González
October 20, 2012
Programming
6
1.5k
¿Dónde están mis interfaces?
RubyConf Argentina 2012 - Charla de Ruby para programadores Java y C#
Jano González
October 20, 2012
Tweet
Share
More Decks by Jano González
See All by Jano González
Containerizing your monolith
janogonzalez
0
210
Migrando a Microservicios
janogonzalez
1
240
Extracting services from a monolith
janogonzalez
3
240
¿Después de 10 años, realmente entiendo esta industria?
janogonzalez
3
390
Microservices in Practice
janogonzalez
7
610
Two programmers in one
janogonzalez
1
120
The Bipolar Programmer
janogonzalez
4
560
Ruby for your two internal programmers
janogonzalez
4
200
Ruby for Java minds
janogonzalez
4
960
Other Decks in Programming
See All in Programming
MicrosoftのPlatform Engineeringガイドを読んで実際になにかやってみた
ymd65536
1
490
ADRを一年運用してみた/adr_after_a_year
hanhan1978
7
2.4k
Behind VS Code Extensions for JavaScript / TypeScript Linnting and Formatting
unvalley
5
1.1k
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
380
検証も兼ねて個人開発でHonoとかと向き合った話
hanetsuki
1
1.3k
What We Can Learn From OSS
inouehi
0
430
Tailwind CSSを本気でカスタマイズする方法
fsubal
14
5.4k
Sheets API使ってみた
toshi0383
2
150
AmperとFleetを使ったAndroidアプリ
yoppie
0
240
dbtのドメイン分割による データ基盤の改善とDigdagとの連携
sakama
0
430
#phpcon_odawara オープン・クローズドなテストフィクスチャを求めて / open closed test fixtures
77web
3
240
Let's learn code review
riofujimon
2
560
Featured
See All Featured
How to name files
jennybc
65
93k
Designing on Purpose - Digital PM Summit 2013
jponch
111
6.5k
Infographics Made Easy
chrislema
238
18k
Robots, Beer and Maslow
schacon
PRO
155
7.9k
Designing Experiences People Love
moore
136
23k
Fontdeck: Realign not Redesign
paulrobertlloyd
76
4.9k
Pencils Down: Stop Designing & Start Developing
hursman
117
11k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
14
1.5k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
The Art of Programming - Codeland 2020
erikaheidi
43
12k
Designing the Hi-DPI Web
ddemaree
276
33k
Adopting Sorbet at Scale
ufuk
69
8.6k
Transcript
¿DÓNDE ESTÁN MIS INTERFACES?
RUBY PARA PROGRAMADORES JAVA (Y C#)
0 EL CHARLISTA
@janogonzalez
HopIn
@dynlangchile
1 LA HISTORIA
JAPÓN 1993
·ͭͱΏ͖ͻΖ
YUKIHIRO MATSUMOTO
MATZ
“RUBY IS DESIGNED TO MAKE PROGRAMMERS HAPPY” - MATZ
LA MEZCLA Smalltalk Perl Lisp
EL RESULTADO
USA 2001
PICKAXE
DINAMARCA 2005
DAVID HEINEMEIER HANSSON
DHH
RAILS 1.0
CHILE 2010
JANO
“RUBY SE VE BUENO, ¿PERO CÓMO SE HACEN LAS INTERFACES?”
- JANO
Este slide se ha dejado en blanco de forma intencional
2 EL LENGUAJE
ES UN LENGUAJE DINÁMICO
SINTAXIS CONCISA Y EXPRESIVA
ORIENTADO A OBJETOS
CON PODEROSAS CUALIDADES DE METAPROGRAMACIÓN
ALGUNAS CARACTERÍSTICAS FUNCIONALES
3 ENTENDIENDO RUBY
SINTÁXIS Y CONVENCIONES
NombreDeClaseOModulo CONSTANTE @nombre_de_atributo @@atributo_de_clase $variable_global nombre_de_metodo metodo_peligroso! metodo_que_pregunta?
OBJETOS
TODOS LOS VALORES SON OBJETOS
"RubyConf Argentina".length(); Java
"RubyConf Argentina".length # => 18 Ruby
Arrays.sort(new String[] {"Hugo","Paco","Luis"}); Java
["Hugo","Paco","Luis"].sort # => ["Hugo","Luis","Paco"] Ruby
Math.abs(-100); Math.abs(new Integer(-100)); Java
-100.abs # => 100 Ruby
foo == null Java
foo.nil? # => true nil.nil? # => true Ruby
NIL OMG
nil.class # => NilClass
Date d = new Date(); Java
d = Date.new Ruby
POO A VECES OCULTA
HAY MUCHOS LITERALES
# Números 3 3.14 0b1000_1000
# Strings 'Hola RubyConf Argentina' "Hola #{conferencia}"
# Símbolos :name :+
# Arrays ['Hugo','Paco','Luis']
# Hashes { :nombre => 'Jano', :apellido => 'González' }
{ nombre: "Jano”, apellido: "González” }
# Expresiones Regulares /^[a-f]+$/
# Rangos 0..1 0...10 “a”..”z”
# Lambdas lambda { |n| n * 2 } ->(n){
n * 2 } ->(n=0){ n * 2 }
EN TODOS LADOS HAY MENSAJES
class Flojo def method_missing(method, *args, &block) puts "Alguien dijo que
hiciera esto: #{method}" end end f = Flojo.new f.tender_la_cama # => "Alguien dijo que hiciera esto: tender_la_cama"
MÉTODOS COMO OPERADORES
4 - 3 # => 1
4.send :-, 3 # => 1
Arrays.asList("Hugo","Paco", "Luis").remove("Luis"); Java
['Hugo','Paco','Luis'] - ['Luis'] # => ['Hugo','Paco'] Ruby
# Ejemplo Set def -(enum) dup.substract(enum) end
# Ejemplo Set require 'set' s = Set.new [1, 10,
100] #=> #<Set: {1, 10, 100}> s - [1] #=> #<Set: {10, 100}>
EXPRESIONES x+y-z
CASI TODO RETORNA UN VALOR
if (estado.equals("Feliz")) { cara = ":)"; } else if (estado.equals("Triste"))
{ cara = ":("; } else { cara = ":|"; } Java
face = case estado when “Feliz” then ":)" when “Triste”
then ":(" else ":|" end # => ":)" Ruby
case estado when “Feliz” then ":)" when “Triste” then ":("
else ":|" end # => ":)" Ruby
a = 3.14159 # => 3.14159
def foo “bar” end # => nil
# Ejemplo gema Sequel def schema @schema ||= get_db_schema end
BLOQUES
3.times do |i| puts i end # 0 # 1
# 2 # => 2 3.times { |i| puts i }
PROGRAMANDO DE FORMA DECLARATIVA
(1..10).select { |n| n.even? } # => [2, 4, 6,
8, 10] (1..10).select(&:even?) # => [2, 4, 6, 8, 10]
(1..100).map { |n| n*2 } (1..100).select { |n| (n %
3) == 0 } (1..100).reduce { |sum,n| sum + n } (1..100).reduce(:+)
AUMENTANDO LA FLUIDEZ
File.open('my.txt').each do |line| puts line if line =~ /jano/ end
DUCK TYPING
public interface DuckLike { Cuack cuack(); } ... public void
doSomething(DuckLike d) { d.cuack(); ... } Java
def do_something(obj) if obj.respond_to? :cuack obj.cuack ... else ... end
end Ruby
MONKEY PATCHING
class Range def even self.select(&:even?) end end (0..10).even # =>
[2, 4, 6, 8, 10]
MÓDULOS
MÓDULOS COMO NAMESPACES
module MyAPI class User ... end def self.configuration ... end
end
user = MyAPI::User.new puts MyAPI::configuration
MÓDULOS COMO MIXINS
module Model def persist ... end end
class Admin < User include Model ... end
3 HERRAMIENTAS
JARS Java
GEMS Ruby
$ ant Java
$ rake Ruby
$ mvn Java
$ gem $ bundle Ruby
Java
$ rbenv o $ rvm Ruby
BUSCANDO GEMAS
4 JRUBY
RUBY + JVM
LO MEJOR DE 2 MUNDOS
require 'java' java_import 'java.util.Date' d = Date.new d.to_gmt_string JRuby
Date d = new Date(); d.toGMTString(); Date.parse("20/03/1982"); Java
d = Date.new d.to_gmt_string Date::parse "20/03/1982" JRuby
MUCHAS OPCIONES DEPLOYMENT WEB
WARBLER
TRINIDAD
TORQUEBOX
PARAÍSO POLÍGLOTA
JRUBY + AKKA
JRUBY + NETTY
JRUBY + HADOOP
JRUBY + STORM
JRUBY + *
1.7.0 COMING SOON
5 LO QUE FALTÓ
EL MODELO DE OBJETOS METAPROGRAMACIÓN BLOQUES, PROCS Y LAMBDAS CHUNKY
BACON
NOS VEMOS EN RUBYCONF AR 2013
SÍ, LOS ESTOY MIRANDO A UDS ORGANIZADORES
6 CONCLUSIONES
ELIGE LA HERRAMIENTA ADECUADA
Y ÚSALA BIEN
7 ¡GRACIAS!