540 likes | 923 Views
Introduction to Ruby on Rails TM. Sergio Ontiveros / Omar Ontiveros Solutionwise Consulting. March, 2009. About Solutionwise. Rails Application Development Rails Development / Consultancy serving both Large Organizations and SME’s Rails Platform Integration (Rails on Java infrastructure)
E N D
Introduction toRuby on RailsTM Sergio Ontiveros / Omar Ontiveros Solutionwise Consulting March, 2009
About Solutionwise • Rails Application Development • Rails Development / Consultancy serving both Large Organizations and SME’s • Rails Platform Integration (Rails on Java infrastructure) • Application Migration to Rails • Web Development Background • Java Platform • Web Applications • Client/Server Applications • .NET (C#, ASP.NET) • Lotus Domino • “Software Artisans” • Involved with Rails / Ruby since 2005 • Presentation Slides www.solutionwise.ca
Audience YOU
Summary • Why Rails • What is Rails • How does it works • Where (How-does it works, part#2) • Ruby Demo • Rails Demo • Q & A
Why RoR? Why do I (you) need to know about it?
In search of “Programmer Happiness”
Toolbar Syndrome What about Tools for “Sophisticated Users” (a.k.a. Developers?)
“Software Renaissance” “As a cultural movement, it encompassed a revival of learning based on classical sources, the development of linear perspective in painting, and gradual but widespread educational reform. Traditionally, this intellectual transformation has resulted in the Renaissance being viewed as a bridge between the Middle Ages and the Modern era.” Source: http://en.wikipedia.org/wiki/Renaissance
Competitive Advantage • Constant change = Perpetual Renewal of Best Practices • Conveys practical software paradigms • Leverage from developer produced tools • Potentially it opens new business opportunities • Lower cost (Open Source)
Fundamental Programming Principles • KISS principle • Automate repetitive tasks • Don’t over engineer solutions • Write less code = Less to maintain + Faster Code • Simple may lead to elegant • Raising levels of abstraction
Your People Matters • What keeps Developers motivated • Use new technology (yes to some extent) • Delivering on time • Productivity • Economic Compensation • Desirable, but what matters is: • Self-motivation (making and creating stuff) • Inherently Passion (for the craft) • Prefer tools that are developer friendly (…Productive)
What is RoR? “Ruby on RailsTM is an open source web application framework that is optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration.” Source: http://rubyonrails.org/ “…It is intended to be used with an Agile development methodology, which is often utilized by web developers for its suitability for short, client-driven projects.” Source: http://en.wikipedia.org/wiki/Ruby_on_Rails
History • Ruby • Truly Object Oriented, dynamic, meta-programming language • Ruby 0.95 in 1995 • Current Release 1.9.1, most deployed Release 1.8.6 • Rails • Extracted by David Heinemeier Hansson (DHH) from Basecamp, a project management tool by 37signals. • CONSTANT CHANGE
RoR is Agile • Manifesto for Agile Software Development • Responding to change over following a plan • Working software over comprehensive documentation • Customer collaboration over contract negotiation • Individuals and interactions over processes and tools
Philosophy • DRY (Don’t Repeat Yourself) • CoC (Convention Over Configuration) – a.k.a “Smart defaults”. • Opinionated (.. and now with options) • Minimalist
YAWF? (Yet Another Web Framework?)
Disruptive • Drastic reduction in development timelines. (1/10) • Prototypes are not thrown away, but rather evolved. • Shatters existing paradigms. • Large applications need complex tools • Enterprise Projects must use Enterprise tools. • Divide and Conquer (“Share nothing”) • The inner workings should be complex • Disposable implementation of business ideas is now possible. • Create, Extend and Mold your own tools to fit your own business domain not the other way around.
Influential • Post-Rails Web Development Era: • Jboss Seam, Grails, Trails (Java) • ASP.NET MVC (.Net ) • Cake, PhpOnTrax (PHP) • Django, Subway (Phyton) • Catalyst, Perl on Rails (Perl) • Future new Frameworks are measured against RoR, in terms of ease of use, simplicity, extensibility and practicality.
RoR and the Organizational Culture • Practical • Trust • Ownership goes in parallel with Responsibility • No database “hugging”. • Change is OK “We had really somewhat missed the Internet boat” Richard Roy – General Manager Microsoft Dec. 1995
“Web Development for All” • Effectively lowering the barrier of entry to Web Application Development, without losing capabilities or ability to implement features. • Heavily reliant on Ruby’s dynamic behaviour • “A script collection SD toolkit”1 for both highly experienced and entry-level developer • RoR can be understood as a “Domain Specific Language (DSL) for developing web applications. “
2009 Fukuoka Ruby Award • Government of Fukuoka Japan raises public awareness of the growing software industry and Ruby www.f-ruby.com
Features • Open Source • MVC • RESTful web architecture • Single Stack • Default Pluggable Single Stack (Rails 3.0) • Minimalist • Integrated Testing
Support in Closed-Source Software Software Company Incident Solution Client $$$
Support in OSS Source Code RoR API Docs Interchange User Mailing Lists Forums
MVC 2.Event Handler 3.Compute Action 5. Render View 1. User Interaction 6. Read model 4. Read/Write model to database
RESTful DATABASE Create Read Update Delete WEB (HTTP) Post Get Put Delete URLs /my-app/clients/new /my-app/clients/1 /my-app/clients/1/edit /my-app/clients/1 • Standard extensible and scalable integration (internal/external)
Single Stack APPLICATION LAYERS Database Layer Presentation Layer Business Logic Middleware (M,L) RoR Stack ActiveRecord ActionView Ruby / DSL ActiveResource • BENEFITS: • Less integration hassles • Improvements in the framework work across layers • Layers are optional
Default Pluggable Stack • Model Mapping (ORM) • Active Record … or Data Mapper or Sequel • View Templates • ERb…. or Haml • Ajax • Prototype/Scriptaculous…. Or JQuery • Controller • ActionController… or Rails Metal/Rack
Minimalist • Minimal instruction that performs one task well • Additional optional parameters • Core is shrinking, extensible features via plug-ins
Integrated Testing • Automated test is critical to accelerate testing and avoid regression defects • Test coverage (80/20) - Critical for non-compiled languages • RoR Testing Artifacts • Fixtures • Functional • Integration • Unit • Mocks
Multiplatform • MRI (Matz’s Ruby Interpreter) • MRI 1.8.6 is widely deployed • MRI 1.8.7 intended as intermediate step towards 1.9.1 • Current Release 1.9.1 (… but wait!) • Jruby • Release version: JRuby1.1.6 (Update: JRuby1.2.0 RC2) • Compatible w/ MRI 1.8.6 support for 1.9 • Rubinius • Not 100% Rails compatible yet • IronRuby • Still Alpha
Deployments • Self-hosting • Traditional Mongrel cluster • Passenger • Cloud Computing • Simple, simpler, simplest
Considerations when using RoR • Encapsulating elements • Create your own APIs (abstractions) when possible • Automation, automation, automation • Source Code Version Control • Old code is commented out • DB assets not under version control • Refactor code as well as your DB Schema • Ref: www.ambysoft.com/books/refactoringDatabases.html
Getting Ruby and RoR • Your favourite database • SQLite (default Rails development database) • MySQL (appropiate for most projects) • PostgreSQL (transactional applications) • http://www.ruby-lang.org/en/downloads • http://www.rubyonrails.org/download
RUBY DEMO
RoR DEMO
“Living interesting times” • Rails - Rails 3.0 (Summer…ish 2009) • Merging MERB/ project into Rails • Progress underway with Rails 2.3 • Rails Metal and Rack • Github – Social code sharing • Ruby • Ruby 1.9.1 • Block variable scope, Additional Lambda syntax, String encoding • Other options materialize (Rubinius/IronRuby)