SlideShare a Scribd company logo
UIKonf App Architecture
&
Data Oriented Design
+------------+ +----------------+
| | | |
| Objects | | Data |
+------------+ +----------------+
| Talk | | Title |
| Speaker | | Description |
| Organizer | | StartTime |
| Volunteer | | EndTime |
| Venue | | Name |
| Break | | TwitterHandle |
| Workshop | | PhotoURL |
| ... | | ... |
| | | |
+------------+ +----------------+
Time slot
[
{
"t_id": "startDay1",
"startTime": "18-09-00",
"endTime": "18-10-00",
"description": "Check in first day",
"locations": [
"Heimathafen Neukölln"
]
},
...
Organizer
...
{
"name": "Maxim Zaks",
"twitter": "@iceX33",
"bio": "Software developer with a history in IDE development,
Web development and even Enterprise Java development
(He was young and under bad influence).
Nowadays working as a game developer (preferably iOS).
Regular visitor and occasional speaker at conferences.",
"photo": "http://www.uikonf.com/static/images/maxim-zaks.png",
"organizer": true
},
...
Speaker
...
{
"name": "Graham Lee",
"twitter": "@iwasleeg",
"bio": "Graham Lee works at Facebook, where he helps people make better tests
so they can help people make better software.
In the past he worked with some other people,
and has written books and blogs so he can work
with people he hasn't met too. His blog is at sicpers.info.",
"photo": "http://www.uikonf.com/static/images/Graham-Lee.png"
},
...
Talk
...
{
"title": "World Modeling",
"speaker_name": "Mike Lee",
"t_id": "session1Day1",
"t_index": 1
},
...
Location
...
{
"name": "Heimathafen Neukölln",
"address": "Karl-Marx-Str. 141, 12043 Berlin",
"description": "Conference venue"
},
...
Import Data from JSON Array
for item in jsonArray {
let entity = context.createEntity()
for pair in (item as! NSDictionary) {
let (key,value) = (pair.key as! String,
pair.value as! JsonValue)
let component = converters[key]!(value)
entity.set(component)
}
}
What is a context?
It's a managing data structure
public class Context {
public func createEntity() -> Entity
public func destroyEntity(entity : Entity)
public func entityGroup(matcher : Matcher) -> Group
}
What's an entity?
Bag of components
Entity
public class Entity {
public func set(c:Component, overwrite:Bool = false)
public func get<C:Component>(ct:C.Type) -> C?
public func has<C:Component>(ct:C.Type) -> Bool
public func remove<C:Component>(ct:C.Type)
}
What's a component
It's just data (value object)
Components
struct NameComponent : Component, DebugPrintable {
let name : String
var debugDescription: String{
return "[(name)]"
}
}
What's a component
It also can be just a flag
struct OrganizerComponent : Component {}
Import Data from JSON Array
for item in jsonArray {
let entity = context.createEntity()
for pair in (item as! NSDictionary) {
let (key,value) = (pair.key as! String,
pair.value as! JsonValue)
let component = converters[key]!(value)
entity.set(component)
}
}
Converters dictionary
typealias Converter = (JsonValue) -> Component
let converters : [String : Converter] = [
"t_id" : {
TimeSlotIdComponent(id: $0 as! String)
},
"t_index" : {
TimeSlotIndexComponent(index: $0 as! Int)
},
...
How does it work with
UIKit
override func viewDidLoad() {
super.viewDidLoad()
groupOfEvents = context.entityGroup(
Matcher.Any(StartTimeComponent, EndTimeComponent))
setNavigationTitleFont()
groupOfEvents.addObserver(self)
context.entityGroup(
Matcher.All(RatingComponent)).addObserver(self)
readDataIntoContext(context)
syncData(context)
}
What's a group?
Subset of Entites
Entity
public class Group : SequenceType {
public var count : Int
public var sortedEntities: [Entity]
public func addObserver(observer : GroupObserver)
public func removeObserver(observer : GroupObserver)
}
override func viewDidLoad() {
super.viewDidLoad()
groupOfEvents = context.entityGroup(
Matcher.Any(StartTimeComponent, EndTimeComponent))
setNavigationTitleFont()
groupOfEvents.addObserver(self)
context.entityGroup(
Matcher.All(RatingComponent)).addObserver(self)
readDataIntoContext(context)
syncData(context)
}
extension TimeLineViewController : GroupObserver {
func entityAdded(entity : Entity) {
if entity.has(RatingComponent){
updateSendButton()
} else {
reload()
}
}
func entityRemoved(entity : Entity,
withRemovedComponent removedComponent : Component) {
if removedComponent is RatingComponent {
return
}
reload()
}
}
private lazy var reload :
dispatch_block_t = dispatch_debounce_block(0.1) {
...
}
override func tableView(tableView: UITableView,
cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let sectionName = sectionNameTable[indexPath.section]()!
let cellIdentifier = cellIdTable[sectionName]!
let cell = tableView.dequeueReusableCellWithIdentifier(
cellIdentifier, forIndexPath: indexPath) as! EntityCell
let cellEntity = cellEntityTable[sectionName]!(indexPath.row)
cell.updateWithEntity(cellEntity, context: context)
return cell as! UITableViewCell
}
protocol EntityCell {
func updateWithEntity(entity : Entity, context : Context)
}
class LocationCell: UITableViewCell, EntityCell {
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var descriptionLabel: UITextView!
func updateWithEntity(entity : Entity, context : Context){
nameLabel.text = entity.get(NameComponent)!.name
let descriptionText = entity.get(DescriptionComponent)?.description
let address = entity.get(AddressComponent)!.address
descriptionLabel.text = descriptionText != nil ?
descriptionText! + "n" + address : address
}
}
struct PhotoComponent : Component, DebugPrintable {
let url : NSURL
let image : UIImage
let loaded : Bool
var debugDescription: String{
return "[(url), loaded: (loaded)]"
}
}
Data:
{
...
"photo": "http://www.uikonf.com/static/images/maxim-zaks.png",
...
}
Converter:
"photo" : {
PhotoComponent(url: NSURL(string:$0 as! String)!,
image : UIImage(named:"person-icon")!, loaded: false)
},
func setPhoto() {
let photoComponent = entity!.get(PhotoComponent)!
imageView.image = photoComponent.image
if !photoComponent.loaded {
...
}
}
var detachedPerson = entity!.detach
cancelLoadingPhoto =
dispatch_after_cancellable(
0.5, dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0))
{
if let data = NSData(contentsOfURL: photoComponent.url),
let image = UIImage(data: data)
{
let photoComponent = detachedPerson.get(PhotoComponent)!
detachedPerson.set(
PhotoComponent(url: photoComponent.url,
image:image, loaded:true),
overwrite: true
)
detachedPerson.sync()
}
}
What's a detached Entity?
It's an Entity implemented as a struct
with a sync method
var detachedPerson = entity!.detach
cancelLoadingPhoto =
dispatch_after_cancellable(
0.5, dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0))
{
if let data = NSData(contentsOfURL: photoComponent.url),
let image = UIImage(data: data)
{
let photoComponent = detachedPerson.get(PhotoComponent)!
detachedPerson.set(
PhotoComponent(url: photoComponent.url,
image:image, loaded:true),
overwrite: true
)
detachedPerson.sync()
}
}
Recap
—Context is a managing Data Structure
—Entity is a bag of components
—Components are just value types
—Groups are subsets on the components
—You can observe groups -> KVO like behavior
—Use detached entity if you want to go on another
queue
Tanks you
Maxim - @iceX33
Links
—UIKonf App on Github
—Blog: Think different about Data Model
—Blog: What is an entity framework
—Book: Data oriented Design (C++ heavy)
—Talk: Data-Oriented Design and C++ (hardcore)

More Related Content

What's hot

Data visualization by Kenneth Odoh
Data visualization by Kenneth OdohData visualization by Kenneth Odoh
Data visualization by Kenneth Odoh
pyconfi
 
Java programs
Java programsJava programs
Java programs
TAUQEER ABBAS
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
Eugene Zharkov
 
Unity 2018からのハイパフォーマンスな機能紹介
Unity 2018からのハイパフォーマンスな機能紹介Unity 2018からのハイパフォーマンスな機能紹介
Unity 2018からのハイパフォーマンスな機能紹介
dena_genom
 
Cycle.js: Functional and Reactive
Cycle.js: Functional and ReactiveCycle.js: Functional and Reactive
Cycle.js: Functional and Reactive
Eugene Zharkov
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2
Mouna Guru
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
Harjinder Singh
 
Hive function-cheat-sheet
Hive function-cheat-sheetHive function-cheat-sheet
Hive function-cheat-sheet
Dr. Volkan OBAN
 
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
TDC218SP | Trilha Kotlin - DSLs in a Kotlin WayTDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
tdc-globalcode
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
greenwop
 
2 a networkflow
2 a networkflow2 a networkflow
2 a networkflow
Aravindharamanan S
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeMongoDB
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with go
Eleanor McHugh
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montageKris Kowal
 
The Ring programming language version 1.5.4 book - Part 42 of 185
The Ring programming language version 1.5.4 book - Part 42 of 185The Ring programming language version 1.5.4 book - Part 42 of 185
The Ring programming language version 1.5.4 book - Part 42 of 185
Mahmoud Samir Fayed
 
mobl
moblmobl
mobl
zefhemel
 
Martin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick ReferenceMartin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick Reference
Seung-Bum Lee
 
Compositional I/O Stream in Scala
Compositional I/O Stream in ScalaCompositional I/O Stream in Scala
Compositional I/O Stream in Scala
C4Media
 
C sharp 8
C sharp 8C sharp 8
C sharp 8
Germán Küber
 
Implementing a many-to-many Relationship with Slick
Implementing a many-to-many Relationship with SlickImplementing a many-to-many Relationship with Slick
Implementing a many-to-many Relationship with Slick
Hermann Hueck
 

What's hot (20)

Data visualization by Kenneth Odoh
Data visualization by Kenneth OdohData visualization by Kenneth Odoh
Data visualization by Kenneth Odoh
 
Java programs
Java programsJava programs
Java programs
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
 
Unity 2018からのハイパフォーマンスな機能紹介
Unity 2018からのハイパフォーマンスな機能紹介Unity 2018からのハイパフォーマンスな機能紹介
Unity 2018からのハイパフォーマンスな機能紹介
 
Cycle.js: Functional and Reactive
Cycle.js: Functional and ReactiveCycle.js: Functional and Reactive
Cycle.js: Functional and Reactive
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
Hive function-cheat-sheet
Hive function-cheat-sheetHive function-cheat-sheet
Hive function-cheat-sheet
 
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
TDC218SP | Trilha Kotlin - DSLs in a Kotlin WayTDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
 
2 a networkflow
2 a networkflow2 a networkflow
2 a networkflow
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with go
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montage
 
The Ring programming language version 1.5.4 book - Part 42 of 185
The Ring programming language version 1.5.4 book - Part 42 of 185The Ring programming language version 1.5.4 book - Part 42 of 185
The Ring programming language version 1.5.4 book - Part 42 of 185
 
mobl
moblmobl
mobl
 
Martin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick ReferenceMartin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick Reference
 
Compositional I/O Stream in Scala
Compositional I/O Stream in ScalaCompositional I/O Stream in Scala
Compositional I/O Stream in Scala
 
C sharp 8
C sharp 8C sharp 8
C sharp 8
 
Implementing a many-to-many Relationship with Slick
Implementing a many-to-many Relationship with SlickImplementing a many-to-many Relationship with Slick
Implementing a many-to-many Relationship with Slick
 

Similar to UIKonf App & Data Driven Design @swift.berlin

Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using Room
Nelson Glauber Leal
 
Improving Correctness with Types Kats Conf
Improving Correctness with Types Kats ConfImproving Correctness with Types Kats Conf
Improving Correctness with Types Kats Conf
Iain Hull
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
Stefano Fago
 
Cocoaheads Meetup / Alex Zimin / Swift magic
Cocoaheads Meetup / Alex Zimin / Swift magicCocoaheads Meetup / Alex Zimin / Swift magic
Cocoaheads Meetup / Alex Zimin / Swift magic
Badoo Development
 
Александр Зимин (Alexander Zimin) — Магия Swift
Александр Зимин (Alexander Zimin) — Магия SwiftАлександр Зимин (Alexander Zimin) — Магия Swift
Александр Зимин (Alexander Zimin) — Магия Swift
CocoaHeads
 
Kotlin Generation
Kotlin GenerationKotlin Generation
Kotlin Generation
Minseo Chayabanjonglerd
 
mobl
moblmobl
IT6801-Service Oriented Architecture-Unit-2-notes
IT6801-Service Oriented Architecture-Unit-2-notesIT6801-Service Oriented Architecture-Unit-2-notes
IT6801-Service Oriented Architecture-Unit-2-notes
Ramco Institute of Technology, Rajapalayam, Tamilnadu, India
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdf
ShaiAlmog1
 
Improving Correctness With Type - Goto Con Berlin
Improving Correctness With Type - Goto Con BerlinImproving Correctness With Type - Goto Con Berlin
Improving Correctness With Type - Goto Con Berlin
Iain Hull
 
OBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .pptOBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .ppt
SaadAsim11
 
Arrays
ArraysArrays
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
Juan Pablo
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
TechMagic
 
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Codemotion
 
Design for succcess with react and storybook.js
Design for succcess with react and storybook.jsDesign for succcess with react and storybook.js
Design for succcess with react and storybook.js
Chris Saylor
 
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
AvitoTech
 
Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"
Fwdays
 

Similar to UIKonf App & Data Driven Design @swift.berlin (20)

Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using Room
 
resume_Alexey_Zaytsev
resume_Alexey_Zaytsevresume_Alexey_Zaytsev
resume_Alexey_Zaytsev
 
Improving Correctness with Types Kats Conf
Improving Correctness with Types Kats ConfImproving Correctness with Types Kats Conf
Improving Correctness with Types Kats Conf
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
 
Cocoaheads Meetup / Alex Zimin / Swift magic
Cocoaheads Meetup / Alex Zimin / Swift magicCocoaheads Meetup / Alex Zimin / Swift magic
Cocoaheads Meetup / Alex Zimin / Swift magic
 
Александр Зимин (Alexander Zimin) — Магия Swift
Александр Зимин (Alexander Zimin) — Магия SwiftАлександр Зимин (Alexander Zimin) — Магия Swift
Александр Зимин (Alexander Zimin) — Магия Swift
 
Kotlin Generation
Kotlin GenerationKotlin Generation
Kotlin Generation
 
mobl
moblmobl
mobl
 
IT6801-Service Oriented Architecture-Unit-2-notes
IT6801-Service Oriented Architecture-Unit-2-notesIT6801-Service Oriented Architecture-Unit-2-notes
IT6801-Service Oriented Architecture-Unit-2-notes
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdf
 
Improving Correctness With Type - Goto Con Berlin
Improving Correctness With Type - Goto Con BerlinImproving Correctness With Type - Goto Con Berlin
Improving Correctness With Type - Goto Con Berlin
 
OBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .pptOBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .ppt
 
Arrays
ArraysArrays
Arrays
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
 
Design for succcess with react and storybook.js
Design for succcess with react and storybook.jsDesign for succcess with react and storybook.js
Design for succcess with react and storybook.js
 
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
 
Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"
 

More from Maxim Zaks

Entity Component System - a different approach to game and app development
Entity Component System - a different approach to game and app developmentEntity Component System - a different approach to game and app development
Entity Component System - a different approach to game and app development
Maxim Zaks
 
Nitty Gritty of Data Serialisation
Nitty Gritty of Data SerialisationNitty Gritty of Data Serialisation
Nitty Gritty of Data Serialisation
Maxim Zaks
 
Wind of change
Wind of changeWind of change
Wind of change
Maxim Zaks
 
Data model mal anders
Data model mal andersData model mal anders
Data model mal anders
Maxim Zaks
 
Talk Binary to Me
Talk Binary to MeTalk Binary to Me
Talk Binary to Me
Maxim Zaks
 
Entity Component System - for App developers
Entity Component System - for App developersEntity Component System - for App developers
Entity Component System - for App developers
Maxim Zaks
 
Beyond JSON - An Introduction to FlatBuffers
Beyond JSON - An Introduction to FlatBuffersBeyond JSON - An Introduction to FlatBuffers
Beyond JSON - An Introduction to FlatBuffers
Maxim Zaks
 
Beyond JSON @ Mobile.Warsaw
Beyond JSON @ Mobile.WarsawBeyond JSON @ Mobile.Warsaw
Beyond JSON @ Mobile.Warsaw
Maxim Zaks
 
Beyond JSON @ dot swift 2016
Beyond JSON @ dot swift 2016Beyond JSON @ dot swift 2016
Beyond JSON @ dot swift 2016
Maxim Zaks
 
Beyond JSON with FlatBuffers
Beyond JSON with FlatBuffersBeyond JSON with FlatBuffers
Beyond JSON with FlatBuffers
Maxim Zaks
 
Basics of Computer Science
Basics of Computer ScienceBasics of Computer Science
Basics of Computer Science
Maxim Zaks
 
Entity system architecture with Unity @Unite Europe 2015
Entity system architecture with Unity @Unite Europe 2015 Entity system architecture with Unity @Unite Europe 2015
Entity system architecture with Unity @Unite Europe 2015
Maxim Zaks
 
Swift the implicit parts
Swift the implicit partsSwift the implicit parts
Swift the implicit partsMaxim Zaks
 
Currying in Swift
Currying in SwiftCurrying in Swift
Currying in Swift
Maxim Zaks
 
Promise of an API
Promise of an APIPromise of an API
Promise of an API
Maxim Zaks
 
96% macoun 2013
96% macoun 201396% macoun 2013
96% macoun 2013Maxim Zaks
 
Diagnose of Agile @ Wooga 04.2013
Diagnose of Agile @ Wooga 04.2013Diagnose of Agile @ Wooga 04.2013
Diagnose of Agile @ Wooga 04.2013Maxim Zaks
 
Start playing @ mobile.cologne 2013
Start playing @ mobile.cologne 2013Start playing @ mobile.cologne 2013
Start playing @ mobile.cologne 2013Maxim Zaks
 
Under Cocos2D Tree @mdvecon 2013
Under Cocos2D Tree @mdvecon 2013Under Cocos2D Tree @mdvecon 2013
Under Cocos2D Tree @mdvecon 2013Maxim Zaks
 
Don&rsquo;t do Agile, be Agile @NSConf 2013
Don&rsquo;t do Agile, be Agile @NSConf 2013Don&rsquo;t do Agile, be Agile @NSConf 2013
Don&rsquo;t do Agile, be Agile @NSConf 2013Maxim Zaks
 

More from Maxim Zaks (20)

Entity Component System - a different approach to game and app development
Entity Component System - a different approach to game and app developmentEntity Component System - a different approach to game and app development
Entity Component System - a different approach to game and app development
 
Nitty Gritty of Data Serialisation
Nitty Gritty of Data SerialisationNitty Gritty of Data Serialisation
Nitty Gritty of Data Serialisation
 
Wind of change
Wind of changeWind of change
Wind of change
 
Data model mal anders
Data model mal andersData model mal anders
Data model mal anders
 
Talk Binary to Me
Talk Binary to MeTalk Binary to Me
Talk Binary to Me
 
Entity Component System - for App developers
Entity Component System - for App developersEntity Component System - for App developers
Entity Component System - for App developers
 
Beyond JSON - An Introduction to FlatBuffers
Beyond JSON - An Introduction to FlatBuffersBeyond JSON - An Introduction to FlatBuffers
Beyond JSON - An Introduction to FlatBuffers
 
Beyond JSON @ Mobile.Warsaw
Beyond JSON @ Mobile.WarsawBeyond JSON @ Mobile.Warsaw
Beyond JSON @ Mobile.Warsaw
 
Beyond JSON @ dot swift 2016
Beyond JSON @ dot swift 2016Beyond JSON @ dot swift 2016
Beyond JSON @ dot swift 2016
 
Beyond JSON with FlatBuffers
Beyond JSON with FlatBuffersBeyond JSON with FlatBuffers
Beyond JSON with FlatBuffers
 
Basics of Computer Science
Basics of Computer ScienceBasics of Computer Science
Basics of Computer Science
 
Entity system architecture with Unity @Unite Europe 2015
Entity system architecture with Unity @Unite Europe 2015 Entity system architecture with Unity @Unite Europe 2015
Entity system architecture with Unity @Unite Europe 2015
 
Swift the implicit parts
Swift the implicit partsSwift the implicit parts
Swift the implicit parts
 
Currying in Swift
Currying in SwiftCurrying in Swift
Currying in Swift
 
Promise of an API
Promise of an APIPromise of an API
Promise of an API
 
96% macoun 2013
96% macoun 201396% macoun 2013
96% macoun 2013
 
Diagnose of Agile @ Wooga 04.2013
Diagnose of Agile @ Wooga 04.2013Diagnose of Agile @ Wooga 04.2013
Diagnose of Agile @ Wooga 04.2013
 
Start playing @ mobile.cologne 2013
Start playing @ mobile.cologne 2013Start playing @ mobile.cologne 2013
Start playing @ mobile.cologne 2013
 
Under Cocos2D Tree @mdvecon 2013
Under Cocos2D Tree @mdvecon 2013Under Cocos2D Tree @mdvecon 2013
Under Cocos2D Tree @mdvecon 2013
 
Don&rsquo;t do Agile, be Agile @NSConf 2013
Don&rsquo;t do Agile, be Agile @NSConf 2013Don&rsquo;t do Agile, be Agile @NSConf 2013
Don&rsquo;t do Agile, be Agile @NSConf 2013
 

Recently uploaded

ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 

Recently uploaded (20)

ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 

UIKonf App & Data Driven Design @swift.berlin

  • 2.
  • 3. +------------+ +----------------+ | | | | | Objects | | Data | +------------+ +----------------+ | Talk | | Title | | Speaker | | Description | | Organizer | | StartTime | | Volunteer | | EndTime | | Venue | | Name | | Break | | TwitterHandle | | Workshop | | PhotoURL | | ... | | ... | | | | | +------------+ +----------------+
  • 4.
  • 5. Time slot [ { "t_id": "startDay1", "startTime": "18-09-00", "endTime": "18-10-00", "description": "Check in first day", "locations": [ "Heimathafen Neukölln" ] }, ...
  • 6. Organizer ... { "name": "Maxim Zaks", "twitter": "@iceX33", "bio": "Software developer with a history in IDE development, Web development and even Enterprise Java development (He was young and under bad influence). Nowadays working as a game developer (preferably iOS). Regular visitor and occasional speaker at conferences.", "photo": "http://www.uikonf.com/static/images/maxim-zaks.png", "organizer": true }, ...
  • 7. Speaker ... { "name": "Graham Lee", "twitter": "@iwasleeg", "bio": "Graham Lee works at Facebook, where he helps people make better tests so they can help people make better software. In the past he worked with some other people, and has written books and blogs so he can work with people he hasn't met too. His blog is at sicpers.info.", "photo": "http://www.uikonf.com/static/images/Graham-Lee.png" }, ...
  • 8. Talk ... { "title": "World Modeling", "speaker_name": "Mike Lee", "t_id": "session1Day1", "t_index": 1 }, ...
  • 9. Location ... { "name": "Heimathafen Neukölln", "address": "Karl-Marx-Str. 141, 12043 Berlin", "description": "Conference venue" }, ...
  • 10. Import Data from JSON Array for item in jsonArray { let entity = context.createEntity() for pair in (item as! NSDictionary) { let (key,value) = (pair.key as! String, pair.value as! JsonValue) let component = converters[key]!(value) entity.set(component) } }
  • 11. What is a context? It's a managing data structure
  • 12. public class Context { public func createEntity() -> Entity public func destroyEntity(entity : Entity) public func entityGroup(matcher : Matcher) -> Group }
  • 13. What's an entity? Bag of components
  • 14. Entity public class Entity { public func set(c:Component, overwrite:Bool = false) public func get<C:Component>(ct:C.Type) -> C? public func has<C:Component>(ct:C.Type) -> Bool public func remove<C:Component>(ct:C.Type) }
  • 15. What's a component It's just data (value object)
  • 16. Components struct NameComponent : Component, DebugPrintable { let name : String var debugDescription: String{ return "[(name)]" } }
  • 17. What's a component It also can be just a flag
  • 19.
  • 20. Import Data from JSON Array for item in jsonArray { let entity = context.createEntity() for pair in (item as! NSDictionary) { let (key,value) = (pair.key as! String, pair.value as! JsonValue) let component = converters[key]!(value) entity.set(component) } }
  • 21. Converters dictionary typealias Converter = (JsonValue) -> Component let converters : [String : Converter] = [ "t_id" : { TimeSlotIdComponent(id: $0 as! String) }, "t_index" : { TimeSlotIndexComponent(index: $0 as! Int) }, ...
  • 22. How does it work with UIKit
  • 23.
  • 24. override func viewDidLoad() { super.viewDidLoad() groupOfEvents = context.entityGroup( Matcher.Any(StartTimeComponent, EndTimeComponent)) setNavigationTitleFont() groupOfEvents.addObserver(self) context.entityGroup( Matcher.All(RatingComponent)).addObserver(self) readDataIntoContext(context) syncData(context) }
  • 26. Entity public class Group : SequenceType { public var count : Int public var sortedEntities: [Entity] public func addObserver(observer : GroupObserver) public func removeObserver(observer : GroupObserver) }
  • 27.
  • 28. override func viewDidLoad() { super.viewDidLoad() groupOfEvents = context.entityGroup( Matcher.Any(StartTimeComponent, EndTimeComponent)) setNavigationTitleFont() groupOfEvents.addObserver(self) context.entityGroup( Matcher.All(RatingComponent)).addObserver(self) readDataIntoContext(context) syncData(context) }
  • 29.
  • 30. extension TimeLineViewController : GroupObserver { func entityAdded(entity : Entity) { if entity.has(RatingComponent){ updateSendButton() } else { reload() } } func entityRemoved(entity : Entity, withRemovedComponent removedComponent : Component) { if removedComponent is RatingComponent { return } reload() } }
  • 31. private lazy var reload : dispatch_block_t = dispatch_debounce_block(0.1) { ... }
  • 32.
  • 33.
  • 34. override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let sectionName = sectionNameTable[indexPath.section]()! let cellIdentifier = cellIdTable[sectionName]! let cell = tableView.dequeueReusableCellWithIdentifier( cellIdentifier, forIndexPath: indexPath) as! EntityCell let cellEntity = cellEntityTable[sectionName]!(indexPath.row) cell.updateWithEntity(cellEntity, context: context) return cell as! UITableViewCell }
  • 35. protocol EntityCell { func updateWithEntity(entity : Entity, context : Context) } class LocationCell: UITableViewCell, EntityCell { @IBOutlet weak var nameLabel: UILabel! @IBOutlet weak var descriptionLabel: UITextView! func updateWithEntity(entity : Entity, context : Context){ nameLabel.text = entity.get(NameComponent)!.name let descriptionText = entity.get(DescriptionComponent)?.description let address = entity.get(AddressComponent)!.address descriptionLabel.text = descriptionText != nil ? descriptionText! + "n" + address : address } }
  • 36.
  • 37. struct PhotoComponent : Component, DebugPrintable { let url : NSURL let image : UIImage let loaded : Bool var debugDescription: String{ return "[(url), loaded: (loaded)]" } }
  • 38. Data: { ... "photo": "http://www.uikonf.com/static/images/maxim-zaks.png", ... } Converter: "photo" : { PhotoComponent(url: NSURL(string:$0 as! String)!, image : UIImage(named:"person-icon")!, loaded: false) },
  • 39. func setPhoto() { let photoComponent = entity!.get(PhotoComponent)! imageView.image = photoComponent.image if !photoComponent.loaded { ... } }
  • 40. var detachedPerson = entity!.detach cancelLoadingPhoto = dispatch_after_cancellable( 0.5, dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)) { if let data = NSData(contentsOfURL: photoComponent.url), let image = UIImage(data: data) { let photoComponent = detachedPerson.get(PhotoComponent)! detachedPerson.set( PhotoComponent(url: photoComponent.url, image:image, loaded:true), overwrite: true ) detachedPerson.sync() } }
  • 41. What's a detached Entity? It's an Entity implemented as a struct with a sync method
  • 42. var detachedPerson = entity!.detach cancelLoadingPhoto = dispatch_after_cancellable( 0.5, dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)) { if let data = NSData(contentsOfURL: photoComponent.url), let image = UIImage(data: data) { let photoComponent = detachedPerson.get(PhotoComponent)! detachedPerson.set( PhotoComponent(url: photoComponent.url, image:image, loaded:true), overwrite: true ) detachedPerson.sync() } }
  • 43. Recap —Context is a managing Data Structure —Entity is a bag of components —Components are just value types —Groups are subsets on the components —You can observe groups -> KVO like behavior —Use detached entity if you want to go on another queue
  • 44. Tanks you Maxim - @iceX33
  • 45. Links —UIKonf App on Github —Blog: Think different about Data Model —Blog: What is an entity framework —Book: Data oriented Design (C++ heavy) —Talk: Data-Oriented Design and C++ (hardcore)