Exploring Active Record

2020-02-27 129浏览

  • 1.Exploring ActiveRecord Leon Confidential
  • 2.Agenda Ø Preface ü Beauty Of Mathematics Ø Metadata ü Reflection; Association; Attribute Ø Hierarchies ü Scoping Ø Wrapping Up 2
  • 3.Introduction
  • 4.FreeWheel是做什么的? 目前90%美国主流电视媒体和运营商使用我们的广告平台。 2014年,我们服务的视频播放超过1250亿次。 4
  • 5.MRM-FreeWheel的旗舰产品 Monetization Rights Management® 5
  • 6.FreeWheel的客户 6
  • 7.ORM Preface
  • 8.归类 Ø 现有煤气灶、水龙头、水壶和火柴摆在您面前,需要烧水时,须进行如下 操作: ü 往水壶里注满水,点燃煤气,把水壶放到煤气灶上。 Ø 假设现在水壶中的水是满的,其他情况不变,又该怎样去做? ü 物理学家的答案:“点燃煤气,再把水壶放上去。” ü 数学家的答案:“只须把水壶中的水倒掉,问题就化归为前面所说的 问题了。” 8
  • 9.Ø Hibernate (JAVA) Ø Entity Framework (C#) Ø SQLBoiler (Golang) Ø Django (Python) Ø ActiveRecord (Ruby) 9
  • 10.Real Life Gem
  • 11.Real-lifeCase:Brand New Copy 11
  • 12.Tasks Split Up Ø DataStructure:ü Association; Reflection; Attribute; Graph Ø Algorithm ü Graph copy ü Topology sort ü Priority queue Ø Detail is evil !! 12
  • 13.ActiveRecord Hierarchies 13
  • 14.ActiveRecord Metadata
  • 15.Beauty Of Mathematics 15
  • 16.Metaphor For Input & Output 16
  • 17.What's Metadata? - Compiler 17
  • 18.What's Metadata? - Association 18
  • 19.Association & Reflection Ø Reflection ü Host; Options ØAssociation:ü Owner ü Reflection ü Target 19
  • 20.20
  • 21.Builder & Reflection & Association 21
  • 22.What's Metadata? - Attribute 22
  • 23.Attribute ØAttribute:two dimensions ü Type • data type; SQL type • casting from/to database type ü Value • Accessor for business model 23
  • 24.24
  • 25.Attribute Accessor 25
  • 26.ActiveRecord Hierarchies
  • 27.Hierarchies 27
  • 28.Scoping Ø Scope Ø Relation Ø Scope vs. Relation Ø Relation vs. Arel 28
  • 29.Scope 29
  • 30.Relation 30
  • 31.Nested Scopes Combined Relation 31
  • 32.Default Scope Combined Relation 32
  • 33.33
  • 34.Wrapping Up & Abstraction
  • 35.Summary Ø Functionalities ü Metadata Management ü Accessor Methods Generation ü Scoping && Relation Ø Design ü Meta Programming ü Multiple Layers Design For Single Responsibility ü Interface Over Implementation Ø Program = Data Structure + Algorithm 35
  • 36.THANKS Confidential