SlideShare ist ein Scribd-Unternehmen logo
1 von 65
Downloaden Sie, um offline zu lesen
Macoun
⌘
Data Model Mal anders
Maxim Zaks
@iceX33
Ablauf
•Philosophie
•Vorstellung von Entitas-Kit
•Ausblick
Worum geht es beim
Programmieren?
EDV
=
Elektronische Datenverarbeitung
Zwei Arten
von Datenverarbeitung?!
Reine Berechnung
=
Datentransformation/Erzeugung
Reine Berechnung
•Gegebener Datensatz
•Transformation-Regelwerk
•Ergebnis
Compiler
Zustandslose WebServices
Funktionale Programmierung
Was ist mit
Web Browser und Apps?
HTML, CSS & JS rein
Pixelwolke raus
Interaktive Berechnung
Interaktive Berechnung
•Vorheriger Zustand + (User) Eingabe
•Transformation-Regelwerk
•Zwischenergebnis
Die Berechnung wird in einer
Schleife durchgeführt
Apps
Spiele
Simulationen
Die Zwischenergebnisse werden
in Datenmodell gespeichert
Welche Art von
Daten gibt es?
Datenarten
•Applikationsbezogene Daten
•Nutzergenerierte Inhalte
•Laufzeit relevante Daten / Applikationszustand
Applikationszustand
mit
OOP
Metapher basiert
•Ein Bankkonto
•Eine Person
•EinVertrag
Geht es auch
mehr
Datenorientiert?
Datenorientiert
•DE22100100500123456789 - IBANComponent
•Maxim Zaks - NameComponent
•XC45332FGD - ContractIdComponent
Class
vs.
Entity
Eine gute Klasse
•Versteckt Daten (encapsulation)
•Bündelt verhalten (cohesion)
•Ist SOLID
•Single responsibility | Open/Closed | Liskov substitution | Interface
segregation | Dependency inversion
Eine Entity
•Bündelt beliebige Komponenten
•Hat keinVerhalten
•Ist auffindbar (querable)
•Kann observiert werden
let ctx = Context()
let e = ctx.createEntity()
e += NameComponent(value: “Maxim Zaks”)
e += IBANComponent(number: “DE22100100500123456789”)
print(e.get(NameComponent.self)?.value) //Optional(“Maxim Zaks”)
e.with { c: IBANComponent in
print(c.number) // DE22100100500123456789
}
Context
verwaltet
Entities
Komponente ist ein Struct,
der `Component` oder
`UniqueComponent`
implementiert
Entity ist ein Wrapper um
[CID: Component]
Eine Entity ist definiert durch
ihre innere Werte
Nicht durch ihre Geburt
Entities können anhand ihrer
Komponenten gefunden werden
let group = ctx.all([A.cid, B.cid], any: [C.cid, D.cid], none:[E.cid])
for e in group {
print(e.has(A.cid))) // true
}
group.withEach { e, c: A in
print(c)
e -= A.cid
}
print(group.count) // 0
Group ist eine Sequenz von
Entity die immer aktuell ist
Implizite und explizite
Entity Klassifizierung
struct Name: Component { let value: String }
struct BirthDay: Component {let value: Date }
struct NumberOfEmployees: Component {let value: Int}
struct Address: Component {let value: String}
let personMatcher = Matcher(all:[Name.cid, BirthDay.cid])
let organisationMatcher = Matcher(all:[Address.cid], none:[BirthDay.cid])
let people = ctx.group(personMatcher)
let organisations = ctx.group(organisationMatcher)
Implizite Klassifizierung durch
all, any, none
Regeln angewandt an Daten
Explizite
Entity Klassifizierung?
struct Person: Component {}
struct Organisation: Component {}
let personMatcher = Person.matcher
let organisationMatcher = Organisation.matcher
let people = ctx.group(personMatcher)
let organisations = ctx.group(organisationMatcher)
Explizite Entity Klassifizierung
durch
“TagComponent”
Explizit und Exklusive?
struct MyType: Component {
enum `Type` { case person, organisation }
let value: Type
}
e += MyType(value: .person)
let group = ctx.group(MyType.matcher)
let people = group.filter { $0.get(MyType.self)?.value == .person }
Indexierung der Werte
struct Name: Component {let value: String}
let ctx = Context()
let nameIndex = ctx.index { (name: Name) -> String in
name.value
}
let entities: Set<Entity> = nameIndex["Maxim"]
Ziehen vs. Drucken
Context, Group und Entity
sind
Observable
public protocol ContextObserver : Observer {
public func created(entity: Entity, in context: Context)
public func created(group: Group, withMatcher matcher: Matcher, in
context: Context)
public func created<T, C>(index: Index<T, C>, in context: Context)
where T : Hashable, C : Component
}
public protocol EntityObserver : Observer {
public func updated(component oldComponent: Component?, with
newComponent: Component, in entity: Entity)
public func removed(component: Component, from entity: Entity)
public func destroyed(entity: Entity)
}
public protocol GroupObserver : Observer {
public func added(entity: Entity, oldComponent: Component?,
newComponent: Component?, in group: Group)
public func updated(entity: Entity, oldComponent: Component?,
newComponent: Component?, in group: Group)
public func removed(entity: Entity, oldComponent: Component?,
newComponent: Component?, in group: Group)
}
Applikationszustand kann
völlig reaktiv und transparent
gemacht werden
Anwendungsmuster
resiapp.io
⌘
CollectionView oder TableView
Basierend auf einer Group
protocol EntityCell {
func setEntity(_ e : Entity)
}
let message = messageGroup.sorted()[indexPath.row]
let cellId = getCellId(message: message)
guard
let cell = tableView.dequeueReusableCell(withIdentifier: cellId) else {
return UITableViewCell()
}
if let cell = cell as? EntityCell {
cell.setEntity(e)
}
return cell
func setEntity(_ e: Entity) {
message.text = e.get(TextComponent.self)?.value
R_Icon.isHidden = !e.has(ShowRComponent.cid)
bgImage.image = e.has(ShowRComponent.cid) ? UIImage(named:
"bubble_neu") : UIImage(named: "buble2")
if let cellSize = e.get(CellSizeComponent.self)?.size {
adjustMessageAndBackground(…)
}
}
Service Locator
“Dependency Injection
für Arme”
struct DocumentManagerRef: UniqueComponent {
let ref: DocumentManager
}
struct ChatViewRef: UniqueComponent {
weak var ref: ChatView?
}
func setupAppContext() {
appContext.setUniqueComponent(DocumentManagerRef(ref: DocumentManager()))
}
enum AppContext {
static var documentManager: DocumentManager? {
return appContext.uniqueComponent(DocumentManagerRef.self)?.ref
}
static var chatView: ChatView? {
return appContext.uniqueComponent(ChatViewRef.self)?.ref
}
}
Component als Event
Userinteraktion ist
Zustandsveränderung
struct LoadingComponent : Component {}
struct LoadedComponent : Component {}
struct ReLoadedComponent : Component {}
struct SelectedAnswerComponent : UniqueComponent {
let index : Int
}
Was ist mit Persistieren?
Was ist mit Multi Threading?
EntitasKit vs. CoreData
•Leichtgewichtig
•Observable
•InMemory (persistieren auf eigene Hand)
•Datenzentriert, kein OOP
•Kein Schema (sehr gut zum improvisieren)
Fragen?
https://github.com/mzaks/
EntitasKit
Vielen Dank
Macoun
⌘

Weitere ähnliche Inhalte

Ähnlich wie Data model mal anders

JSF und JPA effizient kombinieren (W-JAX 2011)
JSF und JPA effizient kombinieren (W-JAX 2011)JSF und JPA effizient kombinieren (W-JAX 2011)
JSF und JPA effizient kombinieren (W-JAX 2011)Michael Kurz
 
Anbindung von Silverlight an RESTful Web Services
Anbindung von Silverlight an RESTful Web ServicesAnbindung von Silverlight an RESTful Web Services
Anbindung von Silverlight an RESTful Web ServicesAndré Wussow
 
Apache CouchDB at PHPUG Karlsruhe, Germany (Jan 27th 2009)
Apache CouchDB at PHPUG Karlsruhe, Germany (Jan 27th 2009)Apache CouchDB at PHPUG Karlsruhe, Germany (Jan 27th 2009)
Apache CouchDB at PHPUG Karlsruhe, Germany (Jan 27th 2009)Nils Adermann
 
Agiles Modellieren mit Domain Specific Languages
Agiles Modellieren mit Domain Specific LanguagesAgiles Modellieren mit Domain Specific Languages
Agiles Modellieren mit Domain Specific LanguagesDominik Hirt
 
Von Typo3 zu Plone - Ein Migrationsbericht
Von Typo3 zu Plone - Ein MigrationsberichtVon Typo3 zu Plone - Ein Migrationsbericht
Von Typo3 zu Plone - Ein MigrationsberichtAndreas Schiweck
 
Go - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare SystemeGo - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare SystemeFrank Müller
 
Big Data Webinar (Deutsch)
Big Data Webinar (Deutsch)Big Data Webinar (Deutsch)
Big Data Webinar (Deutsch)AWS Germany
 
Back to Basics – Webinar 2: Ihre erste MongoDB-Anwendung
Back to Basics – Webinar 2: Ihre erste MongoDB-AnwendungBack to Basics – Webinar 2: Ihre erste MongoDB-Anwendung
Back to Basics – Webinar 2: Ihre erste MongoDB-AnwendungMongoDB
 
Differenzial Analyse in der Praxis (Florian Walther)
Differenzial Analyse in der Praxis (Florian Walther)Differenzial Analyse in der Praxis (Florian Walther)
Differenzial Analyse in der Praxis (Florian Walther)GEEKcon
 
Legacy WebApps mit AngularJS pimpen
Legacy WebApps mit AngularJS pimpenLegacy WebApps mit AngularJS pimpen
Legacy WebApps mit AngularJS pimpenPhilipp Burgmer
 
Legacy Code refaktorisieren
Legacy Code refaktorisierenLegacy Code refaktorisieren
Legacy Code refaktorisierenHendrik Lösch
 
2013-09-12, sfugcgn: CSS-Selektoren für Datenbankabfragen nutzen
2013-09-12, sfugcgn: CSS-Selektoren für Datenbankabfragen nutzen2013-09-12, sfugcgn: CSS-Selektoren für Datenbankabfragen nutzen
2013-09-12, sfugcgn: CSS-Selektoren für Datenbankabfragen nutzenCarsten Hetzel
 
Einführung in die funktionale Programmierung
Einführung in die funktionale ProgrammierungEinführung in die funktionale Programmierung
Einführung in die funktionale ProgrammierungDigicomp Academy AG
 
Entity Framework hinter den Kulissen
Entity Framework hinter den KulissenEntity Framework hinter den Kulissen
Entity Framework hinter den KulissenAndré Krämer
 
2006 - Basta!: Web 2.0 mit asp.net 2.0
2006 - Basta!: Web 2.0 mit asp.net 2.02006 - Basta!: Web 2.0 mit asp.net 2.0
2006 - Basta!: Web 2.0 mit asp.net 2.0Daniel Fisher
 
‘Fehler vorprogrammiert’ Paul Tours, Senior Consultant/Human Inference
‘Fehler vorprogrammiert’ Paul Tours, Senior Consultant/Human Inference‘Fehler vorprogrammiert’ Paul Tours, Senior Consultant/Human Inference
‘Fehler vorprogrammiert’ Paul Tours, Senior Consultant/Human InferenceDataValueTalk
 
“AT Internet Data Explorer Demo” von meinestadt.de
“AT Internet Data Explorer Demo” von meinestadt.de“AT Internet Data Explorer Demo” von meinestadt.de
“AT Internet Data Explorer Demo” von meinestadt.deAT Internet
 
Market Research Meets Business Intelligence
Market Research Meets Business IntelligenceMarket Research Meets Business Intelligence
Market Research Meets Business IntelligenceDataLion
 

Ähnlich wie Data model mal anders (20)

JSF und JPA effizient kombinieren (W-JAX 2011)
JSF und JPA effizient kombinieren (W-JAX 2011)JSF und JPA effizient kombinieren (W-JAX 2011)
JSF und JPA effizient kombinieren (W-JAX 2011)
 
Anbindung von Silverlight an RESTful Web Services
Anbindung von Silverlight an RESTful Web ServicesAnbindung von Silverlight an RESTful Web Services
Anbindung von Silverlight an RESTful Web Services
 
Apache CouchDB at PHPUG Karlsruhe, Germany (Jan 27th 2009)
Apache CouchDB at PHPUG Karlsruhe, Germany (Jan 27th 2009)Apache CouchDB at PHPUG Karlsruhe, Germany (Jan 27th 2009)
Apache CouchDB at PHPUG Karlsruhe, Germany (Jan 27th 2009)
 
Chatbot Hackathon Slidedeck
Chatbot Hackathon SlidedeckChatbot Hackathon Slidedeck
Chatbot Hackathon Slidedeck
 
Agiles Modellieren mit Domain Specific Languages
Agiles Modellieren mit Domain Specific LanguagesAgiles Modellieren mit Domain Specific Languages
Agiles Modellieren mit Domain Specific Languages
 
Von Typo3 zu Plone - Ein Migrationsbericht
Von Typo3 zu Plone - Ein MigrationsberichtVon Typo3 zu Plone - Ein Migrationsbericht
Von Typo3 zu Plone - Ein Migrationsbericht
 
Go - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare SystemeGo - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare Systeme
 
Big Data Webinar (Deutsch)
Big Data Webinar (Deutsch)Big Data Webinar (Deutsch)
Big Data Webinar (Deutsch)
 
Windows Powershell
Windows PowershellWindows Powershell
Windows Powershell
 
Back to Basics – Webinar 2: Ihre erste MongoDB-Anwendung
Back to Basics – Webinar 2: Ihre erste MongoDB-AnwendungBack to Basics – Webinar 2: Ihre erste MongoDB-Anwendung
Back to Basics – Webinar 2: Ihre erste MongoDB-Anwendung
 
Differenzial Analyse in der Praxis (Florian Walther)
Differenzial Analyse in der Praxis (Florian Walther)Differenzial Analyse in der Praxis (Florian Walther)
Differenzial Analyse in der Praxis (Florian Walther)
 
Legacy WebApps mit AngularJS pimpen
Legacy WebApps mit AngularJS pimpenLegacy WebApps mit AngularJS pimpen
Legacy WebApps mit AngularJS pimpen
 
Legacy Code refaktorisieren
Legacy Code refaktorisierenLegacy Code refaktorisieren
Legacy Code refaktorisieren
 
2013-09-12, sfugcgn: CSS-Selektoren für Datenbankabfragen nutzen
2013-09-12, sfugcgn: CSS-Selektoren für Datenbankabfragen nutzen2013-09-12, sfugcgn: CSS-Selektoren für Datenbankabfragen nutzen
2013-09-12, sfugcgn: CSS-Selektoren für Datenbankabfragen nutzen
 
Einführung in die funktionale Programmierung
Einführung in die funktionale ProgrammierungEinführung in die funktionale Programmierung
Einführung in die funktionale Programmierung
 
Entity Framework hinter den Kulissen
Entity Framework hinter den KulissenEntity Framework hinter den Kulissen
Entity Framework hinter den Kulissen
 
2006 - Basta!: Web 2.0 mit asp.net 2.0
2006 - Basta!: Web 2.0 mit asp.net 2.02006 - Basta!: Web 2.0 mit asp.net 2.0
2006 - Basta!: Web 2.0 mit asp.net 2.0
 
‘Fehler vorprogrammiert’ Paul Tours, Senior Consultant/Human Inference
‘Fehler vorprogrammiert’ Paul Tours, Senior Consultant/Human Inference‘Fehler vorprogrammiert’ Paul Tours, Senior Consultant/Human Inference
‘Fehler vorprogrammiert’ Paul Tours, Senior Consultant/Human Inference
 
“AT Internet Data Explorer Demo” von meinestadt.de
“AT Internet Data Explorer Demo” von meinestadt.de“AT Internet Data Explorer Demo” von meinestadt.de
“AT Internet Data Explorer Demo” von meinestadt.de
 
Market Research Meets Business Intelligence
Market Research Meets Business IntelligenceMarket Research Meets Business Intelligence
Market Research Meets Business Intelligence
 

Mehr von 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 developmentMaxim Zaks
 
Nitty Gritty of Data Serialisation
Nitty Gritty of Data SerialisationNitty Gritty of Data Serialisation
Nitty Gritty of Data SerialisationMaxim Zaks
 
Wind of change
Wind of changeWind of change
Wind of changeMaxim Zaks
 
Talk Binary to Me
Talk Binary to MeTalk Binary to Me
Talk Binary to MeMaxim Zaks
 
Entity Component System - for App developers
Entity Component System - for App developersEntity Component System - for App developers
Entity Component System - for App developersMaxim Zaks
 
Beyond JSON - An Introduction to FlatBuffers
Beyond JSON - An Introduction to FlatBuffersBeyond JSON - An Introduction to FlatBuffers
Beyond JSON - An Introduction to FlatBuffersMaxim Zaks
 
Beyond JSON @ Mobile.Warsaw
Beyond JSON @ Mobile.WarsawBeyond JSON @ Mobile.Warsaw
Beyond JSON @ Mobile.WarsawMaxim Zaks
 
Beyond JSON @ dot swift 2016
Beyond JSON @ dot swift 2016Beyond JSON @ dot swift 2016
Beyond JSON @ dot swift 2016Maxim Zaks
 
Beyond JSON with FlatBuffers
Beyond JSON with FlatBuffersBeyond JSON with FlatBuffers
Beyond JSON with FlatBuffersMaxim Zaks
 
Basics of Computer Science
Basics of Computer ScienceBasics of Computer Science
Basics of Computer ScienceMaxim 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
 
UIKonf App & Data Driven Design @swift.berlin
UIKonf App & Data Driven Design @swift.berlinUIKonf App & Data Driven Design @swift.berlin
UIKonf App & Data Driven Design @swift.berlinMaxim 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 SwiftMaxim Zaks
 
Promise of an API
Promise of an APIPromise of an API
Promise of an APIMaxim 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
 

Mehr von 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
 
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
 
UIKonf App & Data Driven Design @swift.berlin
UIKonf App & Data Driven Design @swift.berlinUIKonf App & Data Driven Design @swift.berlin
UIKonf App & Data Driven Design @swift.berlin
 
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
 

Data model mal anders