SlideShare a Scribd company logo
1 of 20
ActiveDomain
                             An Experimental SOLID ORM




Thursday, December 2, 2010
Me!

                    • Franck Verrot
                    • http://twitter.com/cesariogw
                    • http://github.com/cesario

                    • Currently awesoming at Leadformance

Thursday, December 2, 2010
This is all about

                    • Software architecture
                    • Principles I believe in
                    • Current implementations and their limits
                    • ActiveDomain!

Thursday, December 2, 2010
Software Architecture



Thursday, December 2, 2010
SOLID
                               principles
                    • Single Responsibility
                    • Open/Close
                    • Liskov Substitution
                    • Interface Segregation
                    • Dependency Inversion

Thursday, December 2, 2010
Inspired by DDD

                    • The cover sucks
                    • DDD > Your Mom
                    • Entities,Value Objects
                    • Context Boundaries, ...

Thursday, December 2, 2010
Current
                             implementations


Thursday, December 2, 2010
You do that
                                                 ActiveRecord
     1 class Post                     1 class Post < ActiveRecord::Base
   2   include DataMapper::Resource   2   has_many :comments
   3                                  3 end
   4   property :id, Serial
   5
   6   has n, :comments
   7 end




Thursday, December 2, 2010
Pros                     Cons

        •      Convention                  •   Fine-tuning

        •      High Level of Abstraction   •   Magic can be misleading

        •      Easy to learn               •   Hard to specialize




Thursday, December 2, 2010
You might do that too
                                                   ActiveRecord
     1 class Post                       1 class Post < ActiveRecord::Base
   2    include DataMapper::Resource    2   vestal_version
   3    is :nested_set,                 3   acts_as_paranoid
             :scope => [ :user_id ]     4   set_table_name ‘articles’
   4    property :id,    Serial         5   set_primary_key ‘arti_id’
   5    property :title, String         6   has_many :comments,
   6    has n, :comments                7          :through => :articles,
   7 end                                8          :foreign_key => :id
                                        9   before_validate :do_stuff
                                       10   def do_stuff
                                       11     ...
                                       12   end
                                       13 end
Thursday, December 2, 2010
Architecture at risk
                                  (scary title I know)




Thursday, December 2, 2010
Issues

                    • Separation of concerns
                    • Testing the layers independently
                    • Efficiency ( Transactions, Memory footprint)
                    • Side effects (Lazy loading, non-“PORO”)


Thursday, December 2, 2010
ActiveDomain



Thursday, December 2, 2010
Features

                    • “Plain Old Ruby Object”
                    • Unit of Work
                    • DB agnostic from the start
                    • Could be used to build an AR-like ORM
                    • Identity Mapping

Thursday, December 2, 2010
In Action 1/4
                             describe "User" do
                               it "has many posts" do
                                 user = Entity::User.new :email => 'test@test.com'
                                 user.posts << Entity::Post.new(:title => 'Test post')
                                 user.should have(1).post
                               end
                             end

                             module Entity
                               class User
                                 include ActiveModel::Validations
                                 attr_reader :id
                                 attr_accessor :email, :name, :posts
                                 validates :email, :presence => true

                                 def who
                                   "i am #{name} (#{email})"
                                 end

                                 def initialize args = {}
                                   self.email = args.fetch(:email, nil)
                                   self.name = args.fetch(:name, nil)
                                   self.posts = args.fetch(:posts, [])
                                 end
                               end
                             end

Thursday, December 2, 2010
In Action 2/4

                             module Repository
                               class User < ActiveDomain::Repository::Base
                                 adapter :mysql
                                 table   :users
                                 dsn     'mysql://root:@localhost:3306/test'
                               end
                             end




Thursday, December 2, 2010
In Action 3/4
                             module Mapping
                               class User < ActiveDomain::Mapper::Base
                                 entity       Entity::User
                                 repository   Repository::User

                                 map {
                                   id    :id
                                   email :email
                                 }

                                 associations {
                                   has_many Entity::Post,
                                      :as => :posts,
                                      :conditions => { :id => :author_id }
                                 }
                               end
                             end




Thursday, December 2, 2010
In Action 4/4
                             $EM = ActiveDomain::EntityManager::Base.new do
                               register :users, Mapping::User
                             end

                             user = Entity::User.new :email => 'test@test.com'
                             $EM.users.attach(user) #object marked as new
                             $EM.flush #object persisted

                             user_found = $EM.users.find(:email => "test@test.com")
                             user == user_found # => true




Thursday, December 2, 2010
Is it ready yet?

                    • No!
                    • Associations don’t work yet
                    • Identity mapper in progress
                    • Will be released when it’ll work :)

Thursday, December 2, 2010
Thanks for listening!
                                    Q&A


Thursday, December 2, 2010

More Related Content

What's hot

Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Karsten Dambekalns
 
What makes a good bug report?
What makes a good bug report?What makes a good bug report?
What makes a good bug report?Rahul Premraj
 
Doctrator Symfony Live 2011 San Francisco
Doctrator Symfony Live 2011 San FranciscoDoctrator Symfony Live 2011 San Francisco
Doctrator Symfony Live 2011 San Franciscopablodip
 
Entity Query API
Entity Query APIEntity Query API
Entity Query APImarcingy
 

What's hot (6)

Build your own entity with Drupal
Build your own entity with DrupalBuild your own entity with Drupal
Build your own entity with Drupal
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
 
Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3
 
What makes a good bug report?
What makes a good bug report?What makes a good bug report?
What makes a good bug report?
 
Doctrator Symfony Live 2011 San Francisco
Doctrator Symfony Live 2011 San FranciscoDoctrator Symfony Live 2011 San Francisco
Doctrator Symfony Live 2011 San Francisco
 
Entity Query API
Entity Query APIEntity Query API
Entity Query API
 

Viewers also liked

Intergrity Stock Exchange (2)
Intergrity   Stock Exchange (2)Intergrity   Stock Exchange (2)
Intergrity Stock Exchange (2)Niro11
 
Press Book Mathilde Durieux
Press Book Mathilde DurieuxPress Book Mathilde Durieux
Press Book Mathilde DurieuxMathilde Durieux
 
Online mrm ver1.0
Online mrm ver1.0Online mrm ver1.0
Online mrm ver1.0vijaydsouza
 
Learning and Development in Organizations
Learning and Development in OrganizationsLearning and Development in Organizations
Learning and Development in OrganizationsRobert A. Sedlák
 

Viewers also liked (7)

Intergrity Stock Exchange (2)
Intergrity   Stock Exchange (2)Intergrity   Stock Exchange (2)
Intergrity Stock Exchange (2)
 
Press Book Mathilde Durieux
Press Book Mathilde DurieuxPress Book Mathilde Durieux
Press Book Mathilde Durieux
 
Live-Note
Live-NoteLive-Note
Live-Note
 
My Christmas Holidays
My Christmas HolidaysMy Christmas Holidays
My Christmas Holidays
 
Online mrm ver1.0
Online mrm ver1.0Online mrm ver1.0
Online mrm ver1.0
 
Rails is Secure
Rails is SecureRails is Secure
Rails is Secure
 
Learning and Development in Organizations
Learning and Development in OrganizationsLearning and Development in Organizations
Learning and Development in Organizations
 

Similar to ActiveDomain An Experimental SOLID ORM

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
 
Doctrator Symfony Live 2011 Paris
Doctrator Symfony Live 2011 ParisDoctrator Symfony Live 2011 Paris
Doctrator Symfony Live 2011 Parispablodip
 
Pursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHPPursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHPGiorgio Sironi
 
A Tour Through the Groovy Ecosystem
A Tour Through the Groovy EcosystemA Tour Through the Groovy Ecosystem
A Tour Through the Groovy EcosystemLeonard Axelsson
 
Ruby on CouchDB - SimplyStored and RockingChair
Ruby on CouchDB - SimplyStored and RockingChairRuby on CouchDB - SimplyStored and RockingChair
Ruby on CouchDB - SimplyStored and RockingChairJonathan Weiss
 
How to make DSL
How to make DSLHow to make DSL
How to make DSLYukio Goto
 
Diary of a Java dev lost in the .Net world - MugInClermont
Diary of a Java dev lost in the .Net world - MugInClermont Diary of a Java dev lost in the .Net world - MugInClermont
Diary of a Java dev lost in the .Net world - MugInClermont Daniel Petisme
 
Active Support Core Extensions (1)
Active Support Core Extensions (1)Active Support Core Extensions (1)
Active Support Core Extensions (1)RORLAB
 
Pursuing Domain-Driven Design practices in PHP
Pursuing Domain-Driven Design practices in PHPPursuing Domain-Driven Design practices in PHP
Pursuing Domain-Driven Design practices in PHPGiorgio Sironi
 
Apache ant
Apache antApache ant
Apache antkoniik
 
Postobjektové programovanie v Ruby
Postobjektové programovanie v RubyPostobjektové programovanie v Ruby
Postobjektové programovanie v RubyJano Suchal
 
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...MongoDB
 
Cleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryCleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryRebecca Murphey
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMike Friedman
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesLewis Lin 🦊
 
MongoDB London 2013: Data Modeling Examples from the Real World presented by ...
MongoDB London 2013: Data Modeling Examples from the Real World presented by ...MongoDB London 2013: Data Modeling Examples from the Real World presented by ...
MongoDB London 2013: Data Modeling Examples from the Real World presented by ...MongoDB
 
Choosing a Shard key
Choosing a Shard keyChoosing a Shard key
Choosing a Shard keyMongoDB
 

Similar to ActiveDomain An Experimental SOLID ORM (20)

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
 
Doctrator Symfony Live 2011 Paris
Doctrator Symfony Live 2011 ParisDoctrator Symfony Live 2011 Paris
Doctrator Symfony Live 2011 Paris
 
Pursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHPPursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHP
 
Libertyvasion2010
Libertyvasion2010Libertyvasion2010
Libertyvasion2010
 
A Tour Through the Groovy Ecosystem
A Tour Through the Groovy EcosystemA Tour Through the Groovy Ecosystem
A Tour Through the Groovy Ecosystem
 
Ruby on CouchDB - SimplyStored and RockingChair
Ruby on CouchDB - SimplyStored and RockingChairRuby on CouchDB - SimplyStored and RockingChair
Ruby on CouchDB - SimplyStored and RockingChair
 
How to make DSL
How to make DSLHow to make DSL
How to make DSL
 
Diary of a Java dev lost in the .Net world - MugInClermont
Diary of a Java dev lost in the .Net world - MugInClermont Diary of a Java dev lost in the .Net world - MugInClermont
Diary of a Java dev lost in the .Net world - MugInClermont
 
Active Support Core Extensions (1)
Active Support Core Extensions (1)Active Support Core Extensions (1)
Active Support Core Extensions (1)
 
Pursuing Domain-Driven Design practices in PHP
Pursuing Domain-Driven Design practices in PHPPursuing Domain-Driven Design practices in PHP
Pursuing Domain-Driven Design practices in PHP
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 
Apache ant
Apache antApache ant
Apache ant
 
Postobjektové programovanie v Ruby
Postobjektové programovanie v RubyPostobjektové programovanie v Ruby
Postobjektové programovanie v Ruby
 
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
 
Cleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryCleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQuery
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
 
MongoDB London 2013: Data Modeling Examples from the Real World presented by ...
MongoDB London 2013: Data Modeling Examples from the Real World presented by ...MongoDB London 2013: Data Modeling Examples from the Real World presented by ...
MongoDB London 2013: Data Modeling Examples from the Real World presented by ...
 
Chapter2 bag2
Chapter2 bag2Chapter2 bag2
Chapter2 bag2
 
Choosing a Shard key
Choosing a Shard keyChoosing a Shard key
Choosing a Shard key
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
🐬 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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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
 

ActiveDomain An Experimental SOLID ORM

  • 1. ActiveDomain An Experimental SOLID ORM Thursday, December 2, 2010
  • 2. Me! • Franck Verrot • http://twitter.com/cesariogw • http://github.com/cesario • Currently awesoming at Leadformance Thursday, December 2, 2010
  • 3. This is all about • Software architecture • Principles I believe in • Current implementations and their limits • ActiveDomain! Thursday, December 2, 2010
  • 5. SOLID principles • Single Responsibility • Open/Close • Liskov Substitution • Interface Segregation • Dependency Inversion Thursday, December 2, 2010
  • 6. Inspired by DDD • The cover sucks • DDD > Your Mom • Entities,Value Objects • Context Boundaries, ... Thursday, December 2, 2010
  • 7. Current implementations Thursday, December 2, 2010
  • 8. You do that ActiveRecord 1 class Post 1 class Post < ActiveRecord::Base 2 include DataMapper::Resource 2 has_many :comments 3 3 end 4 property :id, Serial 5 6 has n, :comments 7 end Thursday, December 2, 2010
  • 9. Pros Cons • Convention • Fine-tuning • High Level of Abstraction • Magic can be misleading • Easy to learn • Hard to specialize Thursday, December 2, 2010
  • 10. You might do that too ActiveRecord 1 class Post 1 class Post < ActiveRecord::Base 2 include DataMapper::Resource 2 vestal_version 3 is :nested_set, 3 acts_as_paranoid :scope => [ :user_id ] 4 set_table_name ‘articles’ 4 property :id, Serial 5 set_primary_key ‘arti_id’ 5 property :title, String 6 has_many :comments, 6 has n, :comments 7 :through => :articles, 7 end 8 :foreign_key => :id 9 before_validate :do_stuff 10 def do_stuff 11 ... 12 end 13 end Thursday, December 2, 2010
  • 11. Architecture at risk (scary title I know) Thursday, December 2, 2010
  • 12. Issues • Separation of concerns • Testing the layers independently • Efficiency ( Transactions, Memory footprint) • Side effects (Lazy loading, non-“PORO”) Thursday, December 2, 2010
  • 14. Features • “Plain Old Ruby Object” • Unit of Work • DB agnostic from the start • Could be used to build an AR-like ORM • Identity Mapping Thursday, December 2, 2010
  • 15. In Action 1/4 describe "User" do   it "has many posts" do     user = Entity::User.new :email => 'test@test.com'     user.posts << Entity::Post.new(:title => 'Test post')     user.should have(1).post   end end module Entity   class User     include ActiveModel::Validations     attr_reader :id     attr_accessor :email, :name, :posts     validates :email, :presence => true     def who       "i am #{name} (#{email})"     end     def initialize args = {}       self.email = args.fetch(:email, nil)       self.name = args.fetch(:name, nil)       self.posts = args.fetch(:posts, [])     end   end end Thursday, December 2, 2010
  • 16. In Action 2/4 module Repository   class User < ActiveDomain::Repository::Base     adapter :mysql     table :users     dsn 'mysql://root:@localhost:3306/test'   end end Thursday, December 2, 2010
  • 17. In Action 3/4 module Mapping   class User < ActiveDomain::Mapper::Base     entity Entity::User     repository Repository::User     map {       id :id       email :email     }     associations {       has_many Entity::Post, :as => :posts, :conditions => { :id => :author_id }     }   end end Thursday, December 2, 2010
  • 18. In Action 4/4 $EM = ActiveDomain::EntityManager::Base.new do   register :users, Mapping::User end user = Entity::User.new :email => 'test@test.com' $EM.users.attach(user) #object marked as new $EM.flush #object persisted user_found = $EM.users.find(:email => "test@test.com") user == user_found # => true Thursday, December 2, 2010
  • 19. Is it ready yet? • No! • Associations don’t work yet • Identity mapper in progress • Will be released when it’ll work :) Thursday, December 2, 2010
  • 20. Thanks for listening! Q&A Thursday, December 2, 2010

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n