Practically using Glorp                            Karsten Kusche, Georg Heeg eK                                      28.0...
25 Years                              Georg Heeg eKDonnerstag, 30. August 12My Name is Karsten, i work for Georg Heegi wan...
Glorp               Objects                                              Tables              Valley of     „You Don‘t Want...
Objects           Glorp                   Database                                        Classes               Descriptor...
First StepsDonnerstag, 30. August 12Very simple Datastructure - logging messages with severity1 Class: LogItem, with times...
DemoDonnerstag, 30. August 12Create the DescriptorSystem for a LogItem class and its table.
Donnerstag, 30. August 12the video
Writing               session transact: [ aLogItem ].                                 Reading               tenMinutesAgo ...
So much writingDonnerstag, 30. August 12much writing for the descriptorwhen the objects or the tables change, adjust the d...
Donnerstag, 30. August 12the solution to manual labor is automation, next are some technologies that ease the pain
Mapping ToolDonnerstag, 30. August 12part of ObjectStudiodefine the mapping by hand or let the Mapping Tool help you
Active RecordDonnerstag, 30. August 12Got popular in Ruby on RailsUsed in Web VelocityNaming Conventions
Easy                     • If you know the rules of Active Record                     • If you have control over the datab...
Limitations                     • Ugly existing databases                     • Steep learning curve                     •...
Wishes         • Automatic Conversion         • Ease of useDonnerstag, 30. August 12
Built my own Tool                     • Active Record Compiler                     • Creates Classes from Tables          ...
Best Case Scenario                                • Proper Database Description                                • Proper Cl...
Worst                            Best Case Scenario                                    • Proper Database Description      ...
Donnerstag, 30. August 12select database, enter class names, runChange database, run again!Update Domain Model Code, but n...
DemoDonnerstag, 30. August 12create SQLite3 Store Database, create Mapping for it, inspect the databaseshow the created de...
Donnerstag, 30. August 12the video
Benefits                                    • Design in the DB                                    • Quick Recreation       ...
Drawbacks                    • Backpointers                    • Instance Variable NamesDonnerstag, 30. August 12create pr...
Donnerstag, 30. August 12described how to edit your tables in order to get your objectsnow about the opposite approach
Donnerstag, 30. August 12described how to edit your tables in order to get your objectsnow about the opposite approach
O r p h e u sDonnerstag, 30. August 12Orpheus is software we acquired
Donnerstag, 30. August 12One ring to rule them allOne Database schema for all objects
Virtual Mapping   DB Types                             varchar         text          datetime    Tables                  S...
ShortString                   Person                 name: Karsten                object      instVar      value          ...
ShortString                   Person                 name: Karsten                object      instVar      value          ...
ShortString                   Person                 name: Karsten                object      instVar      value          ...
ShortString                   Person                 name: Karsten                object      instVar      value          ...
ShortString                   Person                 name: Karsten                object      instVar      value          ...
Objects                 C1   C2             P1          P2           P3    Virtual                                        ...
Objects   Orpheus    Database                                Classes                Orpheus-               Descriptor-    ...
Donnerstag, 30. August 12Class Model describes classUsed for virtual tableused for mappingcreates constraints on possible ...
Lens MigrationDonnerstag, 30. August 12Orpheus was written in LensPorting to Glorpinteresting problems
Proxies                     • Glorp keeps Proxies                     • == doesn‘t work                 Person            ...
Per Session Objects                     • no Session PoolDonnerstag, 30. August 12Good for seaside, not so good for deskto...
Method InliningDonnerstag, 30. August 12problems on how glorp creates SQL statements
Person                    session read: Person where:[:each |                                         each city country na...
Query Optimization                        Before:                          [:a | a = 2 & (false | true) | NOT(true)]      ...
Glorp BashingDonnerstag, 30. August 12glorp has some strange behavior for somethings
Column Width                      50                   Characters    VS   varchar[20]Donnerstag, 30. August 12Glorp trims ...
Multithreading                                                     Two Sessions                One Process                ...
`´                            Vicious CacheDonnerstag, 30. August 12read object, modify in DB, read again... no changetell...
Modifying Objects                                  Fetch Object                               Start Transaction           ...
Dictionaries                object dictionary at: #a put: 123.                session transact:[                       ses...
<pragma: class>                        #classModelForLogItem:                        #descriptorForLogItem:               ...
Conclusion                              • Glorp is simple, flexible, fast                              • platform independe...
Thanks                            Monument Valley - http://www.flickr.com/photos/aigle_dore/5824866641/                    ...
Upcoming SlideShare
Loading in …5
×

Practically Using Glorp

834 views

Published on

ESUG 2012, Ghent

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
834
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Practically Using Glorp

  1. 1. Practically using Glorp Karsten Kusche, Georg Heeg eK 28.08.2012Donnerstag, 30. August 12
  2. 2. 25 Years Georg Heeg eKDonnerstag, 30. August 12My Name is Karsten, i work for Georg Heegi want to talk about glorphighly flexible object relational mapping framework for Smalltalkthroughout the last year we had several successful projects using Glorp
  3. 3. Glorp Objects Tables Valley of „You Don‘t Want To Be Here“Donnerstag, 30. August 12Objects and Tables are like water and oil, you need a third component for a good resultGlorp is very flexible yet easy to use
  4. 4. Objects Glorp Database Classes Descriptor- Tables System MappingDonnerstag, 30. August 12sits between objects and classesneeds to know classes, tables, their relationshipChange your Objects or your Database, adjust your descriptor system!!
  5. 5. First StepsDonnerstag, 30. August 12Very simple Datastructure - logging messages with severity1 Class: LogItem, with timestamp, message, severitySmall Database, Small descriptor system
  6. 6. DemoDonnerstag, 30. August 12Create the DescriptorSystem for a LogItem class and its table.
  7. 7. Donnerstag, 30. August 12the video
  8. 8. Writing session transact: [ aLogItem ]. Reading tenMinutesAgo := Timestamp now - 10 minutes. session read: LogItem where: [:each | each timestamp > tenMinutesAgo].Donnerstag, 30. August 12
  9. 9. So much writingDonnerstag, 30. August 12much writing for the descriptorwhen the objects or the tables change, adjust the descriptor systemconnect to existing database is boring and time consuming, error prone
  10. 10. Donnerstag, 30. August 12the solution to manual labor is automation, next are some technologies that ease the pain
  11. 11. Mapping ToolDonnerstag, 30. August 12part of ObjectStudiodefine the mapping by hand or let the Mapping Tool help you
  12. 12. Active RecordDonnerstag, 30. August 12Got popular in Ruby on RailsUsed in Web VelocityNaming Conventions
  13. 13. Easy • If you know the rules of Active Record • If you have control over the databaseDonnerstag, 30. August 12
  14. 14. Limitations • Ugly existing databases • Steep learning curve • Debugging problemsDonnerstag, 30. August 12know the conventions, the rulesexisting databases with weird constraints and namesdebugging inference code is no fun
  15. 15. Wishes • Automatic Conversion • Ease of useDonnerstag, 30. August 12
  16. 16. Built my own Tool • Active Record Compiler • Creates Classes from Tables • Creates Mappings from ConstraintsDonnerstag, 30. August 12Reads meta information from database,Supports One-One, One-Many, Many-To-Many Mappings
  17. 17. Best Case Scenario • Proper Database Description • Proper Classes • Working DescriptorSystemDonnerstag, 30. August 12
  18. 18. Worst Best Case Scenario • Proper Database Description • Proper Classes • Working DescriptorSystemDonnerstag, 30. August 12At Least, it creates a basis for your mapping and you can edit
  19. 19. Donnerstag, 30. August 12select database, enter class names, runChange database, run again!Update Domain Model Code, but not your Mapping
  20. 20. DemoDonnerstag, 30. August 12create SQLite3 Store Database, create Mapping for it, inspect the databaseshow the created descriptor system
  21. 21. Donnerstag, 30. August 12the video
  22. 22. Benefits • Design in the DB • Quick Recreation • Smart RecreationDonnerstag, 30. August 12Database Tools provide Simplest way of describing databasesat least SQL Server Management Studio
  23. 23. Drawbacks • Backpointers • Instance Variable NamesDonnerstag, 30. August 12create properly named methods to access methods with weird names
  24. 24. Donnerstag, 30. August 12described how to edit your tables in order to get your objectsnow about the opposite approach
  25. 25. Donnerstag, 30. August 12described how to edit your tables in order to get your objectsnow about the opposite approach
  26. 26. O r p h e u sDonnerstag, 30. August 12Orpheus is software we acquired
  27. 27. Donnerstag, 30. August 12One ring to rule them allOne Database schema for all objects
  28. 28. Virtual Mapping DB Types varchar text datetime Tables ShortString LargeString Timestamp title comment timestamp ObjectDonnerstag, 30. August 12Objects are stored in multiple tablesone table per database-datatypeChange your objects, and your mapping, but not your database
  29. 29. ShortString Person name: Karsten object instVar value city 1 name Karsten 2 name Munich City name: Munich ObjectReferences zip: 80331 object instVar value Objects 1 city 2 id class Integer 1 Person 2 City object instVar value 2 zip 80331Donnerstag, 30. August 12How to store Objects into that kind of database
  30. 30. ShortString Person name: Karsten object instVar value city 1 name Karsten 2 name Munich City name: Munich ObjectReferences zip: 80331 object instVar value Objects 1 city 2 id class Integer 1 Person 2 City object instVar value 2 zip 80331Donnerstag, 30. August 12How to store Objects into that kind of database
  31. 31. ShortString Person name: Karsten object instVar value city 1 name Karsten 2 name Munich City name: Munich ObjectReferences zip: 80331 object instVar value Objects 1 city 2 id class Integer 1 Person 2 City object instVar value 2 zip 80331Donnerstag, 30. August 12How to store Objects into that kind of database
  32. 32. ShortString Person name: Karsten object instVar value city 1 name Karsten 2 name Munich City name: Munich ObjectReferences zip: 80331 object instVar value Objects 1 city 2 id class Integer 1 Person 2 City object instVar value 2 zip 80331Donnerstag, 30. August 12How to store Objects into that kind of database
  33. 33. ShortString Person name: Karsten object instVar value city 1 name Karsten 2 name Munich City name: Munich ObjectReferences zip: 80331 object instVar value Objects 1 city 2 id class Integer 1 Person 2 City object instVar value 2 zip 80331Donnerstag, 30. August 12How to store Objects into that kind of database
  34. 34. Objects C1 C2 P1 P2 P3 Virtual Person Tables City Actual Tiny Date Num Large Bytes Tables String Time ber StringDonnerstag, 30. August 12Create virtual tables that only glorp knows, so that it can work properly.They are created by orpheus automatically
  35. 35. Objects Orpheus Database Classes Orpheus- Descriptor- Tables System MappingDonnerstag, 30. August 12Only describe your classes
  36. 36. Donnerstag, 30. August 12Class Model describes classUsed for virtual tableused for mappingcreates constraints on possible object composition
  37. 37. Lens MigrationDonnerstag, 30. August 12Orpheus was written in LensPorting to Glorpinteresting problems
  38. 38. Proxies • Glorp keeps Proxies • == doesn‘t work Person City name: Karsten name: Köthen city: ProxyDonnerstag, 30. August 12OnewayBecome is slow!
  39. 39. Per Session Objects • no Session PoolDonnerstag, 30. August 12Good for seaside, not so good for desktop client appscannot fetch objects in the background
  40. 40. Method InliningDonnerstag, 30. August 12problems on how glorp creates SQL statements
  41. 41. Person session read: Person where:[:each | each city country name = Germany] Karsten city City countryName Köthen ^self city country name country Country session read: Person where:[:each | Germany each countryName = Germany]Donnerstag, 30. August 12Glorp knows each is a Person and checks for the attributes ,city‘ -> ,country‘ -> ,name‘.the attribute ,countryName‘ does not exist and would create errors
  42. 42. Query Optimization Before: [:a | a = 2 & (false | true) | NOT(true)] After: [:a | a = 2]Donnerstag, 30. August 12Not supported by MS SQL, supported by Postgres -> optimize it away
  43. 43. Glorp BashingDonnerstag, 30. August 12glorp has some strange behavior for somethings
  44. 44. Column Width 50 Characters VS varchar[20]Donnerstag, 30. August 12Glorp trims and doesn‘t notify
  45. 45. Multithreading Two Sessions One Process Per Session VS Share No ObjectsDonnerstag, 30. August 12One session on multiple processes crashes badly and you need to login againsharing objects between sessions also not possible
  46. 46. `´ Vicious CacheDonnerstag, 30. August 12read object, modify in DB, read again... no changetell Query or Session to refresh
  47. 47. Modifying Objects Fetch Object Start Transaction Register Object x Change Object Commit TransactionDonnerstag, 30. August 12
  48. 48. Dictionaries object dictionary at: #a put: 123. session transact:[ session register: object. object dictionary at: #a put: 456. ]Donnerstag, 30. August 12Glorp will not persist that.Copy of Dictionary -> same associations
  49. 49. <pragma: class> #classModelForLogItem: #descriptorForLogItem: #tableForLOGITEM:Donnerstag, 30. August 12it‘s impossible to find these methods using „references of class LogItem“
  50. 50. Conclusion • Glorp is simple, flexible, fast • platform independent • supports complex mappings • tools could be better • we built our own toolsDonnerstag, 30. August 12
  51. 51. Thanks Monument Valley - http://www.flickr.com/photos/aigle_dore/5824866641/ Little Feet - http://www.flickr.com/photos/goulao/173213992 Single pencil - http://www.flickr.com/photos/ardabalkan/353004619 Easy Button - http://www.flickr.com/photos/bravo213/376781221 ObjectStudio © Cincom Systems Inc WebVelocity © Cincom Systems Inc Thumb up - http://www.flickr.com/photos/krissen/6340984211 Birthday cake - http://www.flickr.com/photos/laughingsquid/260374487/ Tools - http://www.flickr.com/photos/zzpza/3269784239 Bus - http://www.flickr.com/photos/eschipul/250836634 Prometheus © 20th Century Fox Lens - http://www.flickr.com/photos/96dpi/682994554/ Bags - http://www.flickr.com/photos/stevendepolo/3407679411/ Skates - http://www.flickr.com/photos/videimage/3981923034/ Balloon http://www.flickr.com/photos/topsynette/4337734907 Braveheart © Paramount Street Fighter © CAPCOM Path - http://www.flickr.com/photos/atoach/3551829101/Donnerstag, 30. August 12

×