Effective Ruby on Rails
Development Using CodeGear’s
Ruby IDE
Shelby Sanders
Principal Engineer
CodeGear

Copyright ©2007 CodeGear. All Rights Reserved.

2007/6/14

Web Application Expectations
Dynamic• Static web pages and images are not enoughInteractive• Rich-client functionality is becoming the norm

Persistent• Data and preferences integrated throughout

Flexible• Retarget content to mobile devices, feeds, webservices
Copyright ©2007 CodeGear. All Rights Reserved.

2

1

Ruby Background
Object-Oriented• Everything is an Object• Everything is extensible

Copyright ©2007 CodeGear. All Rights Reserved.

3

Ruby Background“Duck” Typing (Dynamic Typing)• If something walks like a duck and quacks like aduck, then it can be treated as if it is a duck

Copyright ©2007 CodeGear. All Rights Reserved.

42

Ruby Background
Blocks (Closures)• Arbitrary sections of code which can be passed
around while retaining original context

Copyright ©2007 CodeGear. All Rights Reserved.

5Ruby Background
Modules• Collections of functionality which can be attachedto Classes or Objects• Equivalent of Interfaces, Multiple Inheritance, andAspects

Copyright ©2007 CodeGear. All Rights Reserved.

63

Ruby Background
Method Missing Handler• Allows dynamic instrumentation of functionality atruntime

Copyright ©2007 CodeGear. All Rights Reserved.

7

Ruby Background
Lenient Syntax• Most punctuation is optional,
including parentheses aroundmethod parameters andsemicolons as line endings• Enables natural creation of aDomain Specific Language(DSL) for the task at hand

Copyright ©2007 CodeGear. All Rights Reserved.

84

Rails Background
Extracted from Reality• All features have been used in multiple production
applications before being added to the framework• Features are evolved based on the experience ofthe development community• Deprecation is used to support legacy applications,while allowing the framework and community tomove forward

Copyright ©2007 CodeGear. All Rights Reserved.

9Rails Background
Opinionated Software• Designed around the most common scenarios,
instead of trying to be everything for everyone• Chooses a default configuration which satisfies themost common scenarios• Enforces best practices by default, but allows
deviation when necessary• For instance, the Model-View-Controller pattern isnaturally enforced by the application generators,
layout, and lifecycle

Copyright ©2007 CodeGear. All Rights Reserved.

105

Rails Background
Convention over Configuration• Every Rails application has
the same layout on disk
• All common components havepredefined locations• Accepting the default layout
and configuration, enables
most routing and mapping to
be done automatically

Copyright ©2007 CodeGear. All Rights Reserved.

11

Rails BackgroundDon't Repeat Yourself (DRY)• All configuration and logic should be defined once
• For instance, database schema and structure ofmodel classes doesn’t overlap, instead they
depend on each other to define the whole picture

Copyright ©2007 CodeGear. All Rights Reserved.

126

Rails Background
Full Stack Framework• All common functionality for database-driven webapplications• Object/Relational mapping• Model-View-Controller support• AJAX libraries and helpers• Web services support• Embedded development server• Test management• No need to evaluate, learn, and maintaindependency on multiple third-party frameworks

Copyright ©2007 CodeGear. All Rights Reserved.

13

Rails Development
Component Generation• All major components are generated via built-in or easilyacquired third-party plugins, including:• Models• Migrations• Controllers• Scaffolds (Views)• Web services• Tests• Plugins

Copyright ©2007 CodeGear. All Rights Reserved.

14

7

Rails Development
Scaffolding• Provides default implementation of Create, Read, Update,and Delete (CRUD) Views• Provided via dynamic instrumentation or static code
generation• Supports incremental replacement at the Action granularity

Copyright ©2007 CodeGear. All Rights Reserved.

15

Rails Development
Change Recognition• Automatic recognition of artifact changes and update ofapplication at runtime• The following changes are integrated without a server restart:• Creation of application components• Modification of database schema including relationships• Changes in Model, View, and Controller logic• Routing changes are the exception

Copyright ©2007 CodeGear. All Rights Reserved.

168

Rails Development"Automagic" Object/Relational Mapping• All Model schema, relationship, and validation information isdefined only once
• Most schema information is defined using database-agnostic
syntax• Special cases are defined using the same artifacts

Copyright ©2007 CodeGear. All Rights Reserved.

17

Rails Development"Automagic" Object/Relational Mapping(Continued)• Most model client API is dynamically instrumented at runtime

Copyright ©2007 CodeGear. All Rights Reserved.

18

9

Rails Development
Context Propagation• Request and session data are easily transformed intodatabase objects• Appropriate contextual objects defined in Controller areautomatically propagated to Views

Copyright ©2007 CodeGear. All Rights Reserved.

19

Rails Development
Code Generation Support• Defined via server-side Ruby code
• Generates client-consumed JavaScript, XML, etc

Copyright ©2007 CodeGear. All Rights Reserved.

20

10

Rails Development
Testing Support• Integrated generation of functional, integration, and unit tests
when creating application components• Automation and reusability via mocks, stubs, and fixtures• Leverages standard Ruby testing framework (Test::Unit)• Helper functionality for common web application assertions

Copyright ©2007 CodeGear. All Rights Reserved.

21

Rails Development
Web Services• Built-in support for REST, SOAP, and XML-RPC• Automatic dispatch and marshalling, just like any other view

Copyright ©2007 CodeGear. All Rights Reserved.

2211

Product Overview
Initiation• Complete runtime environment provided duringinstall• Includes Ruby, Rails, gems, plugins, and databases• Wizards• Provide logical creation of application components via
composite code generation• Cheat sheets and instructional videos• Teach usage of Rails and IDE at the same time

Copyright ©2007 CodeGear. All Rights Reserved.

23

Product Overview
Code Generation and Manipulation• Integrated command line environment• Provides natural access to Rails helper scripts• Enhanced by contextual information from IDE• Ruby and Rails specific code completion andrefactoring• Leverages type information based on framework
semantics and conventions• Includes information for dynamically instrumented
functionality

Copyright ©2007 CodeGear. All Rights Reserved.

2412

Product Overview
Archaeology• Analysis of artifact dependencies regardless oflocation and format• Visualization of inbound and outbounddependencies of the current selectionNavigation• Actions enabling seamless movement between
collaborating artifacts• Correlation of URLs to associated actions andvice-versa

Copyright ©2007 CodeGear. All Rights Reserved.

25

Product Overview
Running• Embedded development server runs application inplace• Embedded Mozilla web browser enables realistic
inspection of DOM, request lifecycle, andcontextual information

Debugging• Multiple language support including Ruby andJavaScript• Integrated display of Rails-specific contextualinformation

Copyright ©2007 CodeGear. All Rights Reserved.

2613

References
Release Information• Available in the second half of 2007
• Windows, Mac OS X, RedHat Linux• Pricing has not yet been set

Product Site
• http://www.codegear.com/products/rubyide

Beta Test Signup• Contact CodeGear staff!

Copyright ©2007 CodeGear. All Rights Reserved.

2714