SlideShare a Scribd company logo
1 of 30
From .NET to Rails, A Developers Story Today’s Sponsors
Who the f**k is Colin Gemmell .NET Dev for 3.5 years Webforms, Umbraco, MVC Big on ALT.NET ideals Moved to Ruby on Rails in May 2010
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 DeveloperDeveloper is awesome".second_word NoMethodError: undefined method `second_word' for "developer developerdeveloper":String classString defsecond_work returnself.split(' ')[1] end end "Developer DeveloperDeveloper is awesome".second_word === “Developer” Extension methods anyone?
Changing implementation classZombieKiller    defkill self.shotgun.fire end end zombie_killer=ZombieKiller.new puts(zombie_killer.kill) ===Zombieheadexplodes classZombieKiller defkill self.axe.throw end end zombie_killer=ZombieKiller.new puts(zombie_killer.kill) ===ZombieFalls 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] publicclassZombieKillerTest:SpecificationBase{ privateZombieKillerzombieKiller; privateZombiezombie; publicoverridevoidGiven(){ varrepo=Mock<IZombieKillerRepository>() zombie=newZombie(Strength.Week,Speed.Fast) zombieKiller=newZombieKiller(repo) repo.stub(x=>x.UpdateZombie).returns(true) zombieKiller.weapon=Weapon.Axe } publicoverridevoidWhen(){ zombieKiller.kill(zombie) } [Test] publicvoidshould_depacite_zombie(){ zombie.status.should_eqaul("decapitated") } } publicclassZombieKiller:IZombieKiller{ privateIZombieKillerRepository_repo; publicZombieKiller( IZombieKillerRepositoryrepo){ _repo=repo } publicvoidKill(Zombiezombie){ zombie.status="decapitated" repo.UpdateZombie(zombie) } }
Example RSpec test classZombieKiller defkillzombie zombie.attack_withself.weapon end End classZombie<ActiveRecord::Base defattack_withweapon #do some logic to see             #what happened to zombie self.save      end end describe"when killing a zombie"do classZombie defsave true end end beforedo @zombie=Zombie.new( :strength=>:week,:speed=>:fast) @zombie_killer=ZombieKiller.new( :weapon=>:axe) @zombie_killer.kill(@zombie) end it"should be decapitated if hit with axe"do @zombie.status.shouldeql(: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
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
The Curse of Active Record 1 classSession<ActiveRecord::Base 2     # name > string 3     # code > string 4  5     validates_uniqueness_of:name,:code 6     includeSessionModel 7 8     defgenerate_code 9         returnif!(self.code.nil?||self.code.empty?) 10       full_code="" 11       while(true) 12           code="%04d"%rand(9999) 13           full_code=“ABC#{code}" 14           breakifSession.code_is_unique?(full_code) 15       end 16       self.code=full_code 17    end 18 end 19 moduleSessionModel 20    defself.includedklass 21          klass.extendClassMethods 22    end 23 24    moduleClassMethods 25        defcode_is_unique?(code) 26            returnself.find_by_code(code).nil? 27        end 28    end 29 end Spot the database calls...
The Curse of Active Record classSession<ActiveRecord::Base # name > string # code > string  validates_uniqueness_of:name,:code  x 2 includeSessionModel defgenerate_code returnif!(self.code.nil?||self.code.empty?) full_code="" while(true) code="%04d"%rand(9999) full_code=“ABC#{code}" breakifSession.code_is_unique?(full_code) end self.code=full_code end end moduleSessionModel defself.includedklass klass.extendClassMethods end moduleClassMethods defcode_is_unique?(code) returnself.find_by_code(code).nil? end end end This was production code. The names have been changed to protect the innocent
.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 .NET 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 Ruby Deployment
Deployment Shock horror its a demo
It’s the future “Its the new hotness” – Rob Ashton
From .NET to Rails, A Developers Story Any Questions? E-mail: pythonandchips@gmail.com Blog: pythonandchips.net Twitter: @colin_gemmell Today’s Sponsors

More Related Content

What's hot

Binaries Are Not Only Output
Binaries Are Not Only OutputBinaries Are Not Only Output
Binaries Are Not Only Output
Hajime Morrita
 
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
Anton Arhipov
 
Os practical-presentation
Os practical-presentationOs practical-presentation
Os practical-presentation
Emmanuel Garcia
 
Uazaa uma-farsa-parte 2
Uazaa uma-farsa-parte 2Uazaa uma-farsa-parte 2
Uazaa uma-farsa-parte 2
devninjabr
 

What's hot (20)

Binaries Are Not Only Output
Binaries Are Not Only OutputBinaries Are Not Only Output
Binaries Are Not Only Output
 
ZeroNights: Automating iOS blackbox security scanning
ZeroNights: Automating iOS blackbox security scanningZeroNights: Automating iOS blackbox security scanning
ZeroNights: Automating iOS blackbox security scanning
 
Typescript tips & tricks
Typescript tips & tricksTypescript tips & tricks
Typescript tips & tricks
 
Sniffing Mach Messages
Sniffing Mach MessagesSniffing Mach Messages
Sniffing Mach Messages
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with Groovy
 
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
 
Os practical-presentation
Os practical-presentationOs practical-presentation
Os practical-presentation
 
Sandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooksSandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooks
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?
 
Groovy 2 and beyond
Groovy 2 and beyondGroovy 2 and beyond
Groovy 2 and beyond
 
Swift for-rubyists
Swift for-rubyistsSwift for-rubyists
Swift for-rubyists
 
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPIPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
 
Testing JS with Jasmine
Testing JS with JasmineTesting JS with Jasmine
Testing JS with Jasmine
 
Presentation about ClosureScript fraemework
Presentation about ClosureScript fraemeworkPresentation about ClosureScript fraemework
Presentation about ClosureScript fraemework
 
PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machine
 
Floggy-M3DD-2009-01-21
Floggy-M3DD-2009-01-21Floggy-M3DD-2009-01-21
Floggy-M3DD-2009-01-21
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
CodePolitan Webinar: The Rise of PHP
CodePolitan Webinar: The Rise of PHPCodePolitan Webinar: The Rise of PHP
CodePolitan Webinar: The Rise of PHP
 
Why async matters
Why async mattersWhy async matters
Why async matters
 
Uazaa uma-farsa-parte 2
Uazaa uma-farsa-parte 2Uazaa uma-farsa-parte 2
Uazaa uma-farsa-parte 2
 

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

Picking gem ruby for penetration testers
Picking gem ruby for penetration testersPicking gem ruby for penetration testers
Picking gem ruby for penetration testers
Paolo Perego
 
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
Nick Sieger
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
guileen
 

Similar to From dot net_to_rails (20)

testing.pdf
testing.pdftesting.pdf
testing.pdf
 
Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
 
10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips
 
Jet presentation
Jet presentationJet presentation
Jet presentation
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Picking gem ruby for penetration testers
Picking gem ruby for penetration testersPicking gem ruby for penetration testers
Picking gem ruby for penetration testers
 
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
 
Cleaning your architecture with android architecture components
Cleaning your architecture with android architecture componentsCleaning your architecture with android architecture components
Cleaning your architecture with android architecture components
 
Groovy on Grails by Ziya Askerov
Groovy on Grails by Ziya AskerovGroovy on Grails by Ziya Askerov
Groovy on Grails by Ziya Askerov
 
Grails
GrailsGrails
Grails
 
Grails
GrailsGrails
Grails
 
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
 
Swift Micro-services and AWS Technologies
Swift Micro-services and AWS TechnologiesSwift Micro-services and AWS Technologies
Swift Micro-services and AWS Technologies
 
Speedy TDD with Rails
Speedy TDD with RailsSpeedy TDD with Rails
Speedy TDD with Rails
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
 
How Testability Inspires AngularJS Design / Ran Mizrahi
How Testability Inspires AngularJS Design / Ran MizrahiHow Testability Inspires AngularJS Design / Ran Mizrahi
How Testability Inspires AngularJS Design / Ran Mizrahi
 

Recently uploaded

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Recently uploaded (20)

THE BEST IPTV in GERMANY for 2024: IPTVreel
THE BEST IPTV in  GERMANY for 2024: IPTVreelTHE BEST IPTV in  GERMANY for 2024: IPTVreel
THE BEST IPTV in GERMANY for 2024: IPTVreel
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, Ocado
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 

From dot net_to_rails

  • 1. From .NET to Rails, A Developers Story Today’s Sponsors
  • 2. Who the f**k is Colin Gemmell .NET Dev for 3.5 years Webforms, Umbraco, MVC Big on ALT.NET ideals Moved to Ruby on Rails in May 2010
  • 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.
  • 10. Ruby Ruby Koans (http://rubykoans.com/)
  • 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 DeveloperDeveloper is awesome".second_word NoMethodError: undefined method `second_word' for "developer developerdeveloper":String classString defsecond_work returnself.split(' ')[1] end end "Developer DeveloperDeveloper is awesome".second_word === “Developer” Extension methods anyone?
  • 15. Changing implementation classZombieKiller defkill self.shotgun.fire end end zombie_killer=ZombieKiller.new puts(zombie_killer.kill) ===Zombieheadexplodes classZombieKiller defkill self.axe.throw end end zombie_killer=ZombieKiller.new puts(zombie_killer.kill) ===ZombieFalls 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] publicclassZombieKillerTest:SpecificationBase{ privateZombieKillerzombieKiller; privateZombiezombie; publicoverridevoidGiven(){ varrepo=Mock<IZombieKillerRepository>() zombie=newZombie(Strength.Week,Speed.Fast) zombieKiller=newZombieKiller(repo) repo.stub(x=>x.UpdateZombie).returns(true) zombieKiller.weapon=Weapon.Axe } publicoverridevoidWhen(){ zombieKiller.kill(zombie) } [Test] publicvoidshould_depacite_zombie(){ zombie.status.should_eqaul("decapitated") } } publicclassZombieKiller:IZombieKiller{ privateIZombieKillerRepository_repo; publicZombieKiller( IZombieKillerRepositoryrepo){ _repo=repo } publicvoidKill(Zombiezombie){ zombie.status="decapitated" repo.UpdateZombie(zombie) } }
  • 20. Example RSpec test classZombieKiller defkillzombie zombie.attack_withself.weapon end End classZombie<ActiveRecord::Base defattack_withweapon #do some logic to see #what happened to zombie self.save end end describe"when killing a zombie"do classZombie defsave true end end beforedo @zombie=Zombie.new( :strength=>:week,:speed=>:fast) @zombie_killer=ZombieKiller.new( :weapon=>:axe) @zombie_killer.kill(@zombie) end it"should be decapitated if hit with axe"do @zombie.status.shouldeql(: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. 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
  • 24. The Curse of Active Record 1 classSession<ActiveRecord::Base 2 # name > string 3 # code > string 4 5 validates_uniqueness_of:name,:code 6 includeSessionModel 7 8 defgenerate_code 9 returnif!(self.code.nil?||self.code.empty?) 10 full_code="" 11 while(true) 12 code="%04d"%rand(9999) 13 full_code=“ABC#{code}" 14 breakifSession.code_is_unique?(full_code) 15 end 16 self.code=full_code 17 end 18 end 19 moduleSessionModel 20 defself.includedklass 21 klass.extendClassMethods 22 end 23 24 moduleClassMethods 25 defcode_is_unique?(code) 26 returnself.find_by_code(code).nil? 27 end 28 end 29 end Spot the database calls...
  • 25. The Curse of Active Record classSession<ActiveRecord::Base # name > string # code > string validates_uniqueness_of:name,:code x 2 includeSessionModel defgenerate_code returnif!(self.code.nil?||self.code.empty?) full_code="" while(true) code="%04d"%rand(9999) full_code=“ABC#{code}" breakifSession.code_is_unique?(full_code) end self.code=full_code end end moduleSessionModel defself.includedklass klass.extendClassMethods end moduleClassMethods defcode_is_unique?(code) returnself.find_by_code(code).nil? end end end This was production code. The names have been changed to protect the innocent
  • 26. .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 .NET Deployment
  • 27. 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 Ruby Deployment
  • 29. It’s the future “Its the new hotness” – Rob Ashton
  • 30. From .NET to Rails, A Developers Story Any Questions? E-mail: pythonandchips@gmail.com Blog: pythonandchips.net Twitter: @colin_gemmell Today’s Sponsors