SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

Binaries Are Not Only Output
Binaries Are Not Only OutputBinaries Are Not Only Output
Binaries Are Not Only OutputHajime Morrita
 
ZeroNights: Automating iOS blackbox security scanning
ZeroNights: Automating iOS blackbox security scanningZeroNights: Automating iOS blackbox security scanning
ZeroNights: Automating iOS blackbox security scanningMikhail Sosonkin
 
Typescript tips & tricks
Typescript tips & tricksTypescript tips & tricks
Typescript tips & tricksOri Calvo
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyIván López Martín
 
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
 
Os practical-presentation
Os practical-presentationOs practical-presentation
Os practical-presentationEmmanuel Garcia
 
Sandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooksSandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooksKarlFrank99
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?FITC
 
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 PHPGuilherme Blanco
 
Testing JS with Jasmine
Testing JS with JasmineTesting JS with Jasmine
Testing JS with JasmineEvgeny Gurin
 
PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machinejulien pauli
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
CodePolitan Webinar: The Rise of PHP
CodePolitan Webinar: The Rise of PHPCodePolitan Webinar: The Rise of PHP
CodePolitan Webinar: The Rise of PHPSteeven Salim
 
Why async matters
Why async mattersWhy async matters
Why async matterstimbc
 
Uazaa uma-farsa-parte 2
Uazaa uma-farsa-parte 2Uazaa uma-farsa-parte 2
Uazaa uma-farsa-parte 2devninjabr
 

Mais procurados (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
 

Destaque

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 storypythonandchips
 
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 daemonhaish
 
Zombie PowerPoint by @ericpesik
Zombie PowerPoint by @ericpesikZombie PowerPoint by @ericpesik
Zombie PowerPoint by @ericpesikEric Pesik
 

Destaque (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
 

Semelhante a From dot net_to_rails

10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript TipsTroy Miles
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
 
Picking gem ruby for penetration testers
Picking gem ruby for penetration testersPicking gem ruby for penetration testers
Picking gem ruby for penetration testersPaolo 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 2011Nick Sieger
 
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 componentsDebora Gomez Bertoli
 
Groovy on Grails by Ziya Askerov
Groovy on Grails by Ziya AskerovGroovy on Grails by Ziya Askerov
Groovy on Grails by Ziya AskerovVuqar Suleymanov
 
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 JRubyNick Sieger
 
Swift Micro-services and AWS Technologies
Swift Micro-services and AWS TechnologiesSwift Micro-services and AWS Technologies
Swift Micro-services and AWS TechnologiesSimonPilkington8
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiJackson Tian
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.jsguileen
 
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Ontico
 
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 PindahNick Plante
 
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 MizrahiRan Mizrahi
 

Semelhante a 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
 
Grails
GrailsGrails
Grails
 
Grails
GrailsGrails
Grails
 
Groovy on Grails by Ziya Askerov
Groovy on Grails by Ziya AskerovGroovy on Grails by Ziya Askerov
Groovy on Grails by Ziya Askerov
 
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
 

Último

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Último (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

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