Slide 1

Slide 1 text

Confidential Exploring ActiveRecord Leon Confidential

Slide 2

Slide 2 text

2 Agenda Ø Preface ü Beauty Of Mathematics Ø Metadata ü Reflection; Association; Attribute Ø Hierarchies ü Scoping Ø Wrapping Up

Slide 3

Slide 3 text

Introduction

Slide 4

Slide 4 text

4 FreeWheel是做什么的? 目前90%美国主流电视媒体和运营商使用我们的广告平台。 2014年,我们服务的视频播放超过1250亿次。

Slide 5

Slide 5 text

5 MRM-FreeWheel的旗舰产品 Monetization Rights Management®

Slide 6

Slide 6 text

6 FreeWheel的客户

Slide 7

Slide 7 text

ORM Preface

Slide 8

Slide 8 text

8 归类 Ø 现有煤气灶、水龙头、水壶和火柴摆在您面前,需要烧水时,须进行如下 操作: ü 往水壶里注满水,点燃煤气,把水壶放到煤气灶上。 Ø 假设现在水壶中的水是满的,其他情况不变,又该怎样去做? ü 物理学家的答案:“点燃煤气,再把水壶放上去。” ü 数学家的答案:“只须把水壶中的水倒掉,问题就化归为前面所说的 问题了。”

Slide 9

Slide 9 text

9 Ø Hibernate (JAVA) Ø Entity Framework (C#) Ø SQLBoiler (Golang) Ø Django (Python) Ø ActiveRecord (Ruby)

Slide 10

Slide 10 text

Real Life Gem

Slide 11

Slide 11 text

11 Real-life Case: Brand New Copy

Slide 12

Slide 12 text

12 Tasks Split Up Ø Data Structure: ü Association; Reflection; Attribute; Graph Ø Algorithm ü Graph copy ü Topology sort ü Priority queue Ø Detail is evil !!

Slide 13

Slide 13 text

13 ActiveRecord Hierarchies

Slide 14

Slide 14 text

ActiveRecord Metadata

Slide 15

Slide 15 text

15 Beauty Of Mathematics

Slide 16

Slide 16 text

16 Metaphor For Input & Output

Slide 17

Slide 17 text

17 What's Metadata? - Compiler

Slide 18

Slide 18 text

18 What's Metadata? - Association

Slide 19

Slide 19 text

19 Association & Reflection Ø Reflection ü Host; Options Ø Association: ü Owner ü Reflection ü Target

Slide 20

Slide 20 text

20

Slide 21

Slide 21 text

21 Builder & Reflection & Association

Slide 22

Slide 22 text

22 What's Metadata? - Attribute

Slide 23

Slide 23 text

23 Attribute Ø Attribute: two dimensions ü Type • data type; SQL type • casting from/to database type ü Value • Accessor for business model

Slide 24

Slide 24 text

24

Slide 25

Slide 25 text

25 Attribute Accessor

Slide 26

Slide 26 text

ActiveRecord Hierarchies

Slide 27

Slide 27 text

27 Hierarchies

Slide 28

Slide 28 text

28 Scoping Ø Scope Ø Relation Ø Scope vs. Relation Ø Relation vs. Arel

Slide 29

Slide 29 text

29 Scope

Slide 30

Slide 30 text

30 Relation

Slide 31

Slide 31 text

31 Nested Scopes Combined Relation

Slide 32

Slide 32 text

32 Default Scope Combined Relation

Slide 33

Slide 33 text

33

Slide 34

Slide 34 text

Wrapping Up & Abstraction

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

Confidential THANKS