maglev-a different way to develop with ruby
DESCRIPTION
These are the slides of the Maglev presentation I gave at @RubyConfAr 2012 The code of the example is in githubTRANSCRIPT
agile software development & services
MaglevRubyConf Argentina 2012
Hernán WilkinsonTwitter: @HernanWilkinson
Blog: objectmodels.blogspot.comwww.10pines.com
What is the presentation about
Common WebApp Architecture
Common WebApp Architecture
Issues
Code vs. DataObject vs. Data
Issues
Paradigm Mismatch(Need a translator)
Issues
Design Errors
• Forced by the ORM• Thinking in tables not in objects• Difficult to create test objects – Mock
abuse!• etc
Issues
More time to run!
• Tests run slow!• Starting can take minutes due to
ActiveRecord!
Therefore…
More “Human” TimeBigger Development Cost
Imagine…
Imagine…
Maglev
A…– Transactional– Automatically persisted– Multi-VM – NO RAM restricted
… Object Server
Maglev
• Two Modes:– Transient mode (normal ruby)– Persistent mode – The really interesting one!• Objects are naturally persistent• On Commit, saves transitive closure from a root
object• Transactional memory! (no deadlocks)
Example!
• Investment Accounts – Balance:
• 10 pesos + 5 dollars• 3000 bodens2012 + 600 futureDollarJan2013
• Portfolios– Account composite
• Multiple Web Interface– Sinatra (simple )– Rails
• Using TDD!
Goals
1. No Object-To-RDB Mapping– No Portfolio < ActiveRecord– No id
2. No SQL SELECT…3. No save! or update!4. Separation of concern – No transactional code mixed with model code
5. No Model to Web Framework coupling6. Only Objects!7. Development using TDD
Fulfilling Goals…
• No Object-To-RDB Mapping– No Portfolio < ActiveRecord– No id
• No SQL SELECT
Account Hierarchy
AccountTransaction Hierarchy
Measure Hierarchy
Fulfilling Goals…
• No Model to Web Framework coupling
PortfolioSystem and PortfolioSinatraApplication
Fulfilling Goals…
• No save! or update!• Separation of concern – No transactional code mixed with model
code
Showing the home page
Adding an Account
FREEDOM!!!
Conclusions
• Just Objects!• No ORM! No SQL! No ActiveRecord! • Tests run fast• Developed really fast• No need for mocks! – Bye bye FactoryGirl!• We did not have to worry about– Persistence– Transaccionability– Solved in one place
Conclusions
SimplerEasier
Cheaper…
Happier
Maglev
• Install with: rvm install maglev• Ruby 1.8.7• Rails: – No scaffolding when using just objects– Need to write generators
• Heroku??• Licence– Ruby code open source– VM is not open source
Futurology
Relational Databases will fall in less than 10 years
• Diseño Avanzado de Softaware con Objetos I: 29 de Octubre
• Metaprogramación con Lenguajes de Objetos: 13 de Noviembre
• TDD: 19 de Noviembre
• Diseño Avanzado de Softaware con Objetos II: 4 de Diciembre
(50% de descuento si vinieron a esta conferencia!)http://www.10pines.com/content/cursos-disponibles
Smalltalks 2012
Questions?
agile software development & services
Muchas gracias!
twitter: @10Pines
Argentina
Tel.: +54 (11) 6091-3125Alem 693, 5BBuenos Aires