Slide 1

Slide 1 text

The swifter way of A/B testing implementation Kouhei Takamatsu(@gaopin1534)

Slide 2

Slide 2 text

ࣗݾ঺հ • ߴদ޾ฏ(gaopin1534) • ๭ਓࡐܥاۀۈ຿ • iOSྺ1೥൒͘Β͍ • ΋ͱ΋ͱ͸PHPͱ͔Rubyͱ͔ͱ஥ྑ͠ • try! Swift2018ϘϥϯςΟΞελοϑͯ͠·ͨ͠ • ΢ΟεΩʔͱ͔Ϗʔϧ͕޷͖

Slide 3

Slide 3 text

by Martin Abegglen (https://goo.gl/VwaMZP)

Slide 4

Slide 4 text

ABςετ by Silly Deity (https://goo.gl/HsJgy3)

Slide 5

Slide 5 text

࢖͍ࣺͯͷfunc طଘϩδοΫΛԚછ͢Δ෼ذ ͿΒΓABςετআ٫ͷཱྀ ԿͷABςετ࢒ͬͯΔΜ΍͚ͬʁ ͦͷABɺςετίʔυॻ͚Δʁ ςετίʔυͦ΋ͦ΋͍Δʁ

Slide 6

Slide 6 text

௒໘౗͍͘͞

Slide 7

Slide 7 text

ष͍΋ͷʹ͸֖ by Erwin Soo (https://goo.gl/1AS3mE)

Slide 8

Slide 8 text

ABTesterProtocol associatedtype ABTestPatternType: ABTestPatternProtocol associatedtype ABTestKey: ABTestKeyProtocol func getCurrentPatternKey() -> ABTestKey A/B test logic functions extension ABTesterProtocol { private func getTargetPattern() -> ABTestPatternType? { return getCurrentPatternKey().pattern as? Self.ABTestPatternType } }

Slide 9

Slide 9 text

ABTesterKeyProtocol: RawRepresentable associatedtype ABTestPatternType: ABTestPatternProtocol var pattern: ABTestPatternType { get } ϩάͱͷ࿈݁͠΍͘͢ɺ ͔ͭenum࢖͑ΑײΛग़ͨ͢Ί RawRepresentableʹ४ڌ

Slide 10

Slide 10 text

ABTesterPatternClass: ABTestPatternProtocol ॻ͘ABςετύλʔϯ͝ͱʹ࣮૷ ࣮ࡍͷϩδοΫ͸શ෦͜͜ʹ DefaultΛҰͭ࡞Γɺଞύλʔϯ͸ͦͷࢠʹ શύλʔϯΫϥε͕ಉ͡funcΛ࣋ͭͷ͕ຯḩ A/B test logic functions

Slide 11

Slide 11 text

class CertainABTestPatternDefault: ABTestPatternProtocol { func getLabel() -> String { return "Live long and prosper." } } class CertainABTestPatternB: CertainABTestPatternDefault { override func getLabel() -> String { return "May the force be with us.” } }

Slide 12

Slide 12 text

struct CertainABTester: ABTesterProtocol { func getCurrentPatternKey() -> SomeABTestKey { return .a } typealias ABTestPatternType = SomeABTestPatternDefault typealias ABTestKey = SomeABTestKey func getLable() -> String { return getCurrentPatternKey().pattern.getLabel() } }

Slide 13

Slide 13 text

SomeTester: ABTesterProtocol SomeTestKey: ABTestKeyProtocol var patternͰબ୒ getCurrentKey PatternDefault: ABTestPatternProtocol PatternB: PatternDefault ϩδοΫݺͿ ᶃ ᶄ ᶅ

Slide 14

Slide 14 text

if ABTestManager().getPattern(of: .someABTest) == "B" { label.text = "foo" } else { label.text = "bar" } ͜Ε͕

Slide 15

Slide 15 text

lebel.text = SomeABTester().getLabel() ͜͏ͳΔ

Slide 16

Slide 16 text

Կ͕خ͍͠ʁ • ύλʔϯΛফͯ͠΋Default͕ੜ͖ͯΕ͹ͱΓ͋͑ͣյ Εͳ͍ • ABςετ୯ҐͰ؅ཧͰ͖ͯɺશ෦ด͡ࠐΊΕΔ • ABͲ͔ͬͪʹدͤΔͱ͖͸έʔεΛফ͚ͩ͢ • ύλʔϯ࡟আ࣌ʹABTester͸࢒ͬͯ͠·͏͕ɺޙʑফ ͢΂͖΋ͷ͕ϚʔΩϯάͰ͖͍ͯΔঢ়ଶʹͳ͍ͬͯΔ

Slide 17

Slide 17 text

Կ͕࢒೦ʁ • ϦϑΝΫλ͢Δ༐ؾ͕ͳ͚Ε͹ӬԕʹABTester͕ ࢒Γଓ͚Δ • ͠͹͠͹Ҿ਺Ͱselfͱ͔Λ౉͢ඞཁ͕͋Δ • ໘౗͍͘͞ͷͰಋೖ࣌ʹݏ͕ΒΕΔ • Ұ൪ൃද͔ͨͬͨ͠ʮSwiftͰ੓࣏ฤʯʹଓ͘

Slide 18

Slide 18 text

https://github.com/ gaopin1534/Yebisw ࡞Γ్தͰ͕͢ɺɺɺ

Slide 19

Slide 19 text

͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠