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

Por que Rails?

Por que Rails?

Avatar for Marcelo Boeira

Marcelo Boeira

September 08, 2015
Tweet

More Decks by Marcelo Boeira

Other Decks in Programming

Transcript

  1. I believe people want to express themselves when they program.

    They don't want to fight with the language. Programming languages must feel natural to programmers. 1994 Yukihiro Matsumoto (Matz) ruby
  2. I wanted a script language that was more powerful than

    Perl, and more object- oriented than Python Perl Python Smalltalk Lisp
  3. 2004 Rails is an open-source web framework that is optimised

    for programmer happiness and productivity. David Heinemeier Hansen DHH rails
  4. DRY

  5. SRP

  6. CoC

  7. mvc

  8. MVC

  9. module SoftDelete attr_reader :deleted_at 
 def delete! self.deleted_at = Time.now

    end def deleted? self.deleted_at.present? end def recover! self.deleted_at = nil end end class User include SoftDelete def initialize(name) @name = name end end class Post include SoftDelete def initialize(title) @title = title end end
  10. $ post = Post.new(“Example”) $ post.deleted? false $ post.delete! $

    post.deleted? true $ post.deleted_at 2015-08-24 23:11:37 -0300 $ post.recover! post.deleted? false $ u = User.new(“Marcelo”) $ user.deleted? false $ user.delete! $ user.deleted? true $ user.deleted_at 2015-08-24 23:13:38 -0300 $ user.recover! p.deleted? false
  11. Fixnum String Array Hash 1, 2, 3 “foo” [1, “foo”,

    3, “bar”] { foo: “bar” } Nil TrueClass nil true
  12. Alan Kays Everything is an Object Objects communicate by sending

    and receiving messages Every object is an instance of a class
  13. Alan Kays Everything is an Object Objects communicate by sending

    and receiving messages Every object is an instance of a class
  14. Alan Kays Everything is an Object Objects communicate by sending

    and receiving messages Every object is an instance of a class Objects have their own memory, which consists of other objects.
  15. class User attr_accessor :name def initialize(name) @name = name end

    end $ alan = User.new(“Alan”) $ alan.name => “Alan” $ alan.name.class => String
  16. Alan Kays Everything is an Object Objects communicate by sending

    and receiving messages Every object is an instance of a class Objects have their own memory, which consists of other objects.
  17. Alan Kays Everything is an Object Objects communicate by sending

    and receiving messages Every object is an instance of a class Objects have their own memory, which consists of other objects. The class is the repository for behavior associated with an object.
  18. class User attr_accessor :name … def initials @name.split(“ “).map(&:chr) end

    end $ alan = User.new(“Alan Kays”) $ alan.initials => [“A”, K”]