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

Venturing Into The Wild: A .NET Developer's Exp...

Jon Kruger
April 22, 2012
66

Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer

From CodeMash 2011

Jon Kruger

April 22, 2012
Tweet

Transcript

  1. Independent consultant in Columbus, OH .NET, Ruby on Rails, Agile

    Email: [email protected] Twitter: @JonKruger Blog: http://jonkruger.com/blog
  2. “Sometimes I want to do Ruby because it means that

    I’m more likely to be able to do TDD.” -- Greg Malcolm
  3. public interface IGetObjectService<T> where T : EntityBase { public T

    Get(int id); public IList<T> GetAll(); } public class GetObjectService<T> : IGetObjectService<T> { public GetObjectService(IRepository<T> repository) { } public T Get(int id) { ... } public IList<T> GetAll() { ... } }
  4. create table Users ( id int, name varchar(100), user_status_id int,

    created_at datetime, updated_at datetime ) class User < ActiveRecord::Base belongs_to :user_status has_many :roles, :through => :user_roles validates_length_of :name, :maximum => 100 named_scope :active, :conditions => ["user_status.id = ?", UserStatus::ACTIVE] end
  5. create table Users ( id int, name varchar(100), user_status_id int,

    created_at datetime, updated_at datetime ) class User < ActiveRecord::Base belongs_to :user_status has_many :roles, :through => :user_roles validates_length_of :name, :maximum => 100 named_scope :active, :conditions => ["user_status.id = ?", UserStatus::ACTIVE] end
  6. create table Users ( id int, name varchar(100), user_status_id int,

    created_at datetime, updated_at datetime ) class User < ActiveRecord::Base belongs_to :user_status has_many :roles, :through => :user_roles validates_length_of :name, :maximum => 100 named_scope :active, :conditions => ["user_status.id = ?", UserStatus::ACTIVE] end
  7. create table Users ( id int, name varchar(100), user_status_id int,

    created_at datetime, updated_at datetime ) class User < ActiveRecord::Base belongs_to :user_status has_many :roles, :through => :user_roles validates_length_of :name, :maximum => 100 named_scope :active, :conditions => ["user_status.id = ?", UserStatus::ACTIVE] end
  8. create table Users ( id int, name varchar(100), user_status_id int,

    created_at datetime, updated_at datetime ) class User < ActiveRecord::Base belongs_to :user_status has_many :roles, :through => :user_roles validates_length_of :name, :maximum => 100 named_scope :active, :conditions => ["user_status.id = ?", UserStatus::ACTIVE] end
  9. create table Users ( id int, name varchar(100), user_status_id int,

    created_at datetime, updated_at datetime ) class User < ActiveRecord::Base belongs_to :user_status has_many :roles, :through => :user_roles validates_length_of :name, :maximum => 100 named_scope :active, :conditions => ["user_status.id = ?", UserStatus::ACTIVE] end
  10. public class Employee { public static Employee Load(int id) {

    ... } public bool Save() { ... } public bool Delete() { ... } }  How do I stub out the Load method in a test?  How can I implement cross-cutting concerns (e.g. caching when saving) without duplicating code?
  11. class Employee < ActiveRecord::Base include Cacheable end module Cacheable def

    save Cache.save(self) super end end  In Ruby, I can mix in modules that will modify the class
  12.  Rails for .NET Developers  by Jeff Cohen and

    Brian Eng  Agile Web Development With Rails  by Sam Ruby, Dave Thomas, David Heinemeier Hansson  Programming Ruby 1.9 (aka the “Pickaxe” book)  by Dave Thomas, with Chad Fowler and Andy Hunt  All found at http://pragprog.com
  13.  Ruby Koans  http://rubykoans.com  Railscasts  http://railscasts.com 

    Why’s Poignant Guide To Ruby  http://mislav.uniqpath.com/poignant-guide/