SlideShare a Scribd company logo
From .NET to Rails,
A Developers Story
Who the f**k is
         Colin Gemmell
.NET Dev for 3.5 years
Webforms, MVC, Umbraco
Big on ALT.NET ideals
Moved to Ruby on Rails in May 2010
Started the Glasgow Ruby User Group
  in March 2011
Why Ruby and Rails
Cheaper than developing with .NET

Arguably faster and more productive

Easier to test your code

Open and free development
Why Ruby and Rails
This man pays me to.




      @chrisvmcd
.NET Development Environment

     Window XP/Vista/7


     Visual Studio 20XX

     Resharper or Code Rush
My First Ruby
Development Environment
 Window XP/Vista/7


 Rubymine

 Cygwin

 Ruby Gems


 Interactive Ruby Console (irb)
Windows Problems
Rails traditionally deployed on Linux OS

Gem’s often use Linux kernal methods
or Linux Libraries

Engineyard investing on Rails development with
  windows
Development Environment
  VMware workstation

   Ubuntu


   Rubymine
   VIM + a lot of plugins

   Ruby Gems


   Interactive Ruby Console (irb)
Development Environment
   Find what is right for you.
Ruby
Ruby Koans (http://rubykoans.com/)
Ruby and SOLID

Single responsibility

Open/Closed

Liskov Substitution

Interface Segregation

Dependency Injection
Ruby and loose coupling

In .NET we use Interface and Dependency
  Injection to achieve loose coupling

Ruby is loosely coupled by design.

Everything and anything can be changed.

Thanks to being a dynamic language and……
Ruby and Monkey Patching
Add New Functionality to Ruby
"Developer Developer Developer is awesome".second_word

NoMethodError: undefined method `second_word' for "developer developer
  developer":String


class String
   def second_work
     return self.split(' ')[1]
   end
end

"Developer Developer Developer is awesome".second_word
=== “Developer”




              Extension methods anyone?
Changing implementation
 class ZombieKiller
   def kill
      self.shotgun.fire
   end
 end
 zombie_killer = ZombieKiller.new
 puts(zombie_killer.kill)
 === Zombie head explodes

 class ZombieKiller
    def kill
      self.axe.throw
    end
 end

 zombie_killer = ZombieKiller.new
 puts(zombie_killer.kill)
 === Zombie Falls off
Are you scared yet?
If the idea of monkey patching scares you a
   little, it probably should. Can you imagine
   debugging code where the String class had
   subtly different behaviours from the String
   you've learned to use? Monkey patching can
   be incredibly dangerous in the wrong hands.
                                        Jeff Atwood


http://www.codinghorror.com/blog/2008/07/monkeypatching-for-humans.html
Testing Ruby and Rails
Testing Ruby and Rails

Testing ensures code behaves correctly

Tests ensure code compiles

Debugging support patchy at best

Its all right, testing is a lot simpler
How I Tested .NET

[TestFixture]                                           public class ZombieKiller : IZombieKiller {
public class ZombieKillerTest : SpecificationBase{          private IZombieKillerRepository _repo;
  private ZombieKiller zombieKiller;                        public ZombieKiller(
  private Zombie zombie;                                            IZombieKillerRepository repo){
                                                                  _repo = repo;
                                                            }
    public override void Given(){
      var repo = Mock<IZombieKillerRepository>();
                                                            public void Kill(Zombie zombie){
      zombie = new Zombie(Strength.Week,                         zombie.status = "decapitated“;
      Speed.Fast);                                               repo.UpdateZombie(zombie);
      zombieKiller = new ZombieKiller(repo);                }
      repo.stub(x => x.UpdateZombie).returns(true);     }
      zombieKiller.weapon = Weapon.Axe;
    }

    public override void When(){
           zombieKiller.kill(zombie);
    }

    [Test]
    public void should_depacite_zombie(){
           zombie.status.should_eqaul("decapitated");
    }
}
Example RSpec test
describe "when killing a zombie" do             class ZombieKiller
  class Zombie                                     def kill zombie
     def save                                        zombie.attack_with self.weapon
       true                                        end
     end                                        End
  end
                                                class Zombie < ActiveRecord::Base
  before do                                        def attack_with weapon
     @zombie = Zombie.new(                          #do some logic to see
                                                    #what happened to zombie
         :strength => :week, :speed => :fast)
                                                    self.save
     @zombie_killer = ZombieKiller.new(
                                                  end
         :weapon => :axe)
                                                end
     @zombie_killer.kill(@zombie)
  end

  it "should be decapitated if hit with axe"
    do
      @zombie.status.should eql(:decapitated)
  end
end
Range of Testing

In .NET there are a lot of test frameworks

Ruby test frameworks include TestUnit, RSpec,
  Shoulda and Cucumber

Rails encourages testing at all levels.

All extremely well documented.
The Rails Way
One project layout and only one layout
Principle of least surprise
Change it at your own risk
Heavily based on conventions e.g.
  ZombieController > ZombieControllerSpec
  Zombie > ZombieSpec (or ZombieTest)
  Zombie > ZombieController
This can be applied to .NET too
The Curse of Active Record
Makes really fast to get going with project

The number one reason for slow apps (IMHO)

Is to easy to write code that over uses the
   database

Often don’t/forget to think about DB
The Curse of Active Record
1 class Session < ActiveRecord::Base        19 module SessionModel
2    # name > string                        20 def self.included klass
3    # code > string                        21      klass.extend ClassMethods
                                            22 end
4                                           23
5    validates_uniqueness_of :name, :code   24 module ClassMethods
6    include SessionModel                   25     def code_is_unique?(code)
7                                           26       return self.find_by_code(code).nil?
8    def generate_code                      27     end
                                            28 end
9       return if !(self.code.nil? ||       29 end
     self.code.empty?)
10      full_code = ""
11      while (true)
12        code = "%04d" % rand(9999)
13        full_code = “ABC#{code}"
14         break if
      Session.code_is_unique?(full_code)
15       end
16       self.code = full_code
17     end
18   end




Spot the database calls...
The Curse of Active Record
class Session < ActiveRecord::Base          module SessionModel
 # name > string                             def self.included klass
 # code > string                              klass.extend ClassMethods
                                             end

 validates_uniqueness_of :name, :code x 2    module ClassMethods
 include SessionModel                            def code_is_unique?(code)
                                                return self.find_by_code(code).nil?
 def generate_code                            end
                                             end
  return if !(self.code.nil? ||             end
    self.code.empty?)
  full_code = ""
  while (true)
   code = "%04d" % rand(9999)
   full_code = “ABC#{code}"
    break if
    Session.code_is_unique?(full_code)
  end
  self.code = full_code
 end
end



This was production code. The names have
been changed to protect the innocent
.NET Deployment
.NET deployment predominantly through FTP or
  copy to file share

But what about databases, migrations, queues,
  externals dependencies etc.

Fear common place on deployment day
Ruby Deployment
Deployment is a solved problem in Rails
Built on several parts
Database migration come out of the box
Bundler gets dependency
Use of Chef or Capistrano for externals or
  configuration changes
Platform as a service combine all of these e.g.
  Heroku, Engineyard, Brightbox
Deployment
Shock horror its a demo
From .NET to Rails,
      A Developers Story
Any Questions?
E-mail: pythonandchips@gmail.com
Blog: pythonandchips.net
Twitter: @colin_gemmell
Rails Scaling
Scaling Rails
John Adams, Twitter operations




     http://tinyurl.com/6j4mqqb

More Related Content

What's hot

Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
Nick Sieger
 
Groovy 2 and beyond
Groovy 2 and beyondGroovy 2 and beyond
Groovy 2 and beyond
Guillaume Laforge
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
Charles Nutter
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracerrahulrevo
 
Jvm internals 2015 - CorkJUG
Jvm internals 2015 - CorkJUGJvm internals 2015 - CorkJUG
Jvm internals 2015 - CorkJUG
Luiz Fernando Teston
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter Slides
Alexandra Masterson
 
JRuby in Java Projects
JRuby in Java ProjectsJRuby in Java Projects
JRuby in Java Projects
jazzman1980
 
Aprendendo solid com exemplos
Aprendendo solid com exemplosAprendendo solid com exemplos
Aprendendo solid com exemplos
vinibaggio
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Anton Arhipov
 
7 Sins of Java fixed in Kotlin
7 Sins of Java fixed in Kotlin7 Sins of Java fixed in Kotlin
7 Sins of Java fixed in Kotlin
Luca Guadagnini
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends旻琦 潘
 
The Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumThe Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup Belgium
Matthias Noback
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
Ecommerce Solution Provider SysIQ
 
Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013
Guillaume Laforge
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
Hiro Asari
 
Shark
Shark Shark
Shark
ytoshima
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Anton Arhipov
 
Android JNI
Android JNIAndroid JNI
Android JNI
Siva Ramakrishna kv
 

What's hot (20)

Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Groovy 2 and beyond
Groovy 2 and beyondGroovy 2 and beyond
Groovy 2 and beyond
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracer
 
Jvm internals 2015 - CorkJUG
Jvm internals 2015 - CorkJUGJvm internals 2015 - CorkJUG
Jvm internals 2015 - CorkJUG
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter Slides
 
JRuby in Java Projects
JRuby in Java ProjectsJRuby in Java Projects
JRuby in Java Projects
 
Aprendendo solid com exemplos
Aprendendo solid com exemplosAprendendo solid com exemplos
Aprendendo solid com exemplos
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012
 
7 Sins of Java fixed in Kotlin
7 Sins of Java fixed in Kotlin7 Sins of Java fixed in Kotlin
7 Sins of Java fixed in Kotlin
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
The Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumThe Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup Belgium
 
The Joy Of Ruby
The Joy Of RubyThe Joy Of Ruby
The Joy Of Ruby
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
Shark
Shark Shark
Shark
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
 
Android JNI
Android JNIAndroid JNI
Android JNI
 

Viewers also liked

Cooking environments with chef
Cooking environments with chefCooking environments with chef
Cooking environments with chefpythonandchips
 
From .Net to Rails, A developers story
From .Net to Rails, A developers storyFrom .Net to Rails, A developers story
From .Net to Rails, A developers story
pythonandchips
 
Linux Daemon Writting
Linux Daemon WrittingLinux Daemon Writting
Linux Daemon Writtingwinsopc
 
PCD - Process control daemon
PCD - Process control daemonPCD - Process control daemon
PCD - Process control daemon
haish
 
Zombie PowerPoint by @ericpesik
Zombie PowerPoint by @ericpesikZombie PowerPoint by @ericpesik
Zombie PowerPoint by @ericpesik
Eric Pesik
 

Viewers also liked (7)

Cooking environments with chef
Cooking environments with chefCooking environments with chef
Cooking environments with chef
 
From .Net to Rails, A developers story
From .Net to Rails, A developers storyFrom .Net to Rails, A developers story
From .Net to Rails, A developers story
 
Linux Daemon Writting
Linux Daemon WrittingLinux Daemon Writting
Linux Daemon Writting
 
PCD - Process control daemon
PCD - Process control daemonPCD - Process control daemon
PCD - Process control daemon
 
Linux Network Management
Linux Network ManagementLinux Network Management
Linux Network Management
 
Processes
ProcessesProcesses
Processes
 
Zombie PowerPoint by @ericpesik
Zombie PowerPoint by @ericpesikZombie PowerPoint by @ericpesik
Zombie PowerPoint by @ericpesik
 

Similar to From dot net_to_rails

Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
Frederic Jean
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
Luiz Fernando Teston
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
Charles Nutter
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
Thomas Lundström
 
Ruby for C# Developers
Ruby for C# DevelopersRuby for C# Developers
Ruby for C# Developers
Cory Foy
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
bobmcwhirter
 
Ruby.new @ VilniusRB
Ruby.new @ VilniusRBRuby.new @ VilniusRB
Ruby.new @ VilniusRB
Vidmantas Kabošis
 
Ruby: Beyond the Basics
Ruby: Beyond the BasicsRuby: Beyond the Basics
Ruby: Beyond the Basics
Michael Koby
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
Burke Libbey
 
GUI Programming with MacRuby
GUI Programming with MacRubyGUI Programming with MacRuby
GUI Programming with MacRubyErik Berlin
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRubyelliando dias
 
JavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdfJavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdf
ranjanadeore1
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deployment
Thilo Utke
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
JRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMJRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVM
Raimonds Simanovskis
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
 
Modified "Why MacRuby Matters"
Modified "Why MacRuby Matters"Modified "Why MacRuby Matters"
Modified "Why MacRuby Matters"
Sean McCune
 
Magic in ruby
Magic in rubyMagic in ruby
Magic in ruby
David Lin
 
Ruby Under The Hood
Ruby Under The HoodRuby Under The Hood
Ruby Under The Hood
craig lehmann
 

Similar to From dot net_to_rails (20)

Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
 
Ruby for C# Developers
Ruby for C# DevelopersRuby for C# Developers
Ruby for C# Developers
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
Ruby.new @ VilniusRB
Ruby.new @ VilniusRBRuby.new @ VilniusRB
Ruby.new @ VilniusRB
 
Ruby: Beyond the Basics
Ruby: Beyond the BasicsRuby: Beyond the Basics
Ruby: Beyond the Basics
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
GUI Programming with MacRuby
GUI Programming with MacRubyGUI Programming with MacRuby
GUI Programming with MacRuby
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
JavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdfJavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdf
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deployment
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
JRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMJRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVM
 
Why MacRuby Matters
Why MacRuby MattersWhy MacRuby Matters
Why MacRuby Matters
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
Modified "Why MacRuby Matters"
Modified "Why MacRuby Matters"Modified "Why MacRuby Matters"
Modified "Why MacRuby Matters"
 
Magic in ruby
Magic in rubyMagic in ruby
Magic in ruby
 
Ruby Under The Hood
Ruby Under The HoodRuby Under The Hood
Ruby Under The Hood
 

Recently uploaded

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 

Recently uploaded (20)

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 

From dot net_to_rails

  • 1. From .NET to Rails, A Developers Story
  • 2. Who the f**k is Colin Gemmell .NET Dev for 3.5 years Webforms, MVC, Umbraco Big on ALT.NET ideals Moved to Ruby on Rails in May 2010 Started the Glasgow Ruby User Group in March 2011
  • 3. Why Ruby and Rails Cheaper than developing with .NET Arguably faster and more productive Easier to test your code Open and free development
  • 4. Why Ruby and Rails This man pays me to. @chrisvmcd
  • 5. .NET Development Environment Window XP/Vista/7 Visual Studio 20XX Resharper or Code Rush
  • 6. My First Ruby Development Environment Window XP/Vista/7 Rubymine Cygwin Ruby Gems Interactive Ruby Console (irb)
  • 7. Windows Problems Rails traditionally deployed on Linux OS Gem’s often use Linux kernal methods or Linux Libraries Engineyard investing on Rails development with windows
  • 8. Development Environment VMware workstation Ubuntu Rubymine VIM + a lot of plugins Ruby Gems Interactive Ruby Console (irb)
  • 9. Development Environment Find what is right for you.
  • 11. Ruby and SOLID Single responsibility Open/Closed Liskov Substitution Interface Segregation Dependency Injection
  • 12. Ruby and loose coupling In .NET we use Interface and Dependency Injection to achieve loose coupling Ruby is loosely coupled by design. Everything and anything can be changed. Thanks to being a dynamic language and……
  • 13. Ruby and Monkey Patching
  • 14. Add New Functionality to Ruby "Developer Developer Developer is awesome".second_word NoMethodError: undefined method `second_word' for "developer developer developer":String class String def second_work return self.split(' ')[1] end end "Developer Developer Developer is awesome".second_word === “Developer” Extension methods anyone?
  • 15. Changing implementation class ZombieKiller def kill self.shotgun.fire end end zombie_killer = ZombieKiller.new puts(zombie_killer.kill) === Zombie head explodes class ZombieKiller def kill self.axe.throw end end zombie_killer = ZombieKiller.new puts(zombie_killer.kill) === Zombie Falls off
  • 16. Are you scared yet? If the idea of monkey patching scares you a little, it probably should. Can you imagine debugging code where the String class had subtly different behaviours from the String you've learned to use? Monkey patching can be incredibly dangerous in the wrong hands. Jeff Atwood http://www.codinghorror.com/blog/2008/07/monkeypatching-for-humans.html
  • 18. Testing Ruby and Rails Testing ensures code behaves correctly Tests ensure code compiles Debugging support patchy at best Its all right, testing is a lot simpler
  • 19. How I Tested .NET [TestFixture] public class ZombieKiller : IZombieKiller { public class ZombieKillerTest : SpecificationBase{ private IZombieKillerRepository _repo; private ZombieKiller zombieKiller; public ZombieKiller( private Zombie zombie; IZombieKillerRepository repo){ _repo = repo; } public override void Given(){ var repo = Mock<IZombieKillerRepository>(); public void Kill(Zombie zombie){ zombie = new Zombie(Strength.Week, zombie.status = "decapitated“; Speed.Fast); repo.UpdateZombie(zombie); zombieKiller = new ZombieKiller(repo); } repo.stub(x => x.UpdateZombie).returns(true); } zombieKiller.weapon = Weapon.Axe; } public override void When(){ zombieKiller.kill(zombie); } [Test] public void should_depacite_zombie(){ zombie.status.should_eqaul("decapitated"); } }
  • 20. Example RSpec test describe "when killing a zombie" do class ZombieKiller class Zombie def kill zombie def save zombie.attack_with self.weapon true end end End end class Zombie < ActiveRecord::Base before do def attack_with weapon @zombie = Zombie.new( #do some logic to see #what happened to zombie :strength => :week, :speed => :fast) self.save @zombie_killer = ZombieKiller.new( end :weapon => :axe) end @zombie_killer.kill(@zombie) end it "should be decapitated if hit with axe" do @zombie.status.should eql(:decapitated) end end
  • 21. Range of Testing In .NET there are a lot of test frameworks Ruby test frameworks include TestUnit, RSpec, Shoulda and Cucumber Rails encourages testing at all levels. All extremely well documented.
  • 22. The Rails Way One project layout and only one layout Principle of least surprise Change it at your own risk Heavily based on conventions e.g. ZombieController > ZombieControllerSpec Zombie > ZombieSpec (or ZombieTest) Zombie > ZombieController This can be applied to .NET too
  • 23. The Curse of Active Record Makes really fast to get going with project The number one reason for slow apps (IMHO) Is to easy to write code that over uses the database Often don’t/forget to think about DB
  • 24. The Curse of Active Record 1 class Session < ActiveRecord::Base 19 module SessionModel 2 # name > string 20 def self.included klass 3 # code > string 21 klass.extend ClassMethods 22 end 4 23 5 validates_uniqueness_of :name, :code 24 module ClassMethods 6 include SessionModel 25 def code_is_unique?(code) 7 26 return self.find_by_code(code).nil? 8 def generate_code 27 end 28 end 9 return if !(self.code.nil? || 29 end self.code.empty?) 10 full_code = "" 11 while (true) 12 code = "%04d" % rand(9999) 13 full_code = “ABC#{code}" 14 break if Session.code_is_unique?(full_code) 15 end 16 self.code = full_code 17 end 18 end Spot the database calls...
  • 25. The Curse of Active Record class Session < ActiveRecord::Base module SessionModel # name > string def self.included klass # code > string klass.extend ClassMethods end validates_uniqueness_of :name, :code x 2 module ClassMethods include SessionModel def code_is_unique?(code) return self.find_by_code(code).nil? def generate_code end end return if !(self.code.nil? || end self.code.empty?) full_code = "" while (true) code = "%04d" % rand(9999) full_code = “ABC#{code}" break if Session.code_is_unique?(full_code) end self.code = full_code end end This was production code. The names have been changed to protect the innocent
  • 26. .NET Deployment .NET deployment predominantly through FTP or copy to file share But what about databases, migrations, queues, externals dependencies etc. Fear common place on deployment day
  • 27. Ruby Deployment Deployment is a solved problem in Rails Built on several parts Database migration come out of the box Bundler gets dependency Use of Chef or Capistrano for externals or configuration changes Platform as a service combine all of these e.g. Heroku, Engineyard, Brightbox
  • 29. From .NET to Rails, A Developers Story Any Questions? E-mail: pythonandchips@gmail.com Blog: pythonandchips.net Twitter: @colin_gemmell
  • 31. Scaling Rails John Adams, Twitter operations http://tinyurl.com/6j4mqqb