SlideShare a Scribd company logo
hipster oriented
programming
Jens Ravens
Developer at nerdgeschoss
iOS/ OS X (Swift)
Server / Backend (Ruby)
@JensRavens
jensravens.de
nerdgeschoss.de
I hate monads already. Even if it’s
the most useful, elegant thing - it’s
all what’s wrong about hype based
hipster-programming in one word.
- tweet after UIKonf
Is it really functional
programming if you don't give a
talk about it?
- @alejandrocrosa
This talk is not about
functional programming.
What is a hipster anyway?
a person who follows the latest
trends and fashions, especially those
regarded as being outside the
cultural mainstream.
- Wikipedia
orientation
Imperative
Do this 5 times!
func nullToNil(dict: [String: AnyObject])->[String: AnyObject]{
var cleaned = [String: AnyObject]()
for (key, value) in dict {
if !(value is NSNull) {
cleaned[key] = value
}
}
return cleaned
}
Functional
Same input, same output.
let l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
let sum = l.reduce(+) // 55
Object Oriented
Put your family of objects in a
room and let them talk.
Protocol Oriented
You have a lot of equatable,
comparable, parseable, archiveable,
transmittable, displayable objects.
Spaghetti Oriented
JSON parsing.
What is state anyway?
class ViewController: UIViewController, UITableViewDelegate {
var selectedItem: Item?
func updateView() {
// do something to update the display
}
func tableView(tableView: UITableView,
didSelectRowAtIndexPath indexPath: NSIndexPath) {
selectedItem = findItemAtIndex(indexPath)
}
}
Question State How to recognise?
IP
imperative
How? a lot of nested loops and assignments
OOP
object oriented
How?
(but encapsulated)
encapsulated
state
seperation of concerns
“unix principle”
POP
protocol oriented
What? encapsulated
objects implementing hundreds
of protocols.
FP
functional
What? no state.
you have no idea what it’s doing,
but it’s short and beautiful.
FRP
functional reactive
When?
over my dead
lambda.
you’re constantly flatMapping
They all mix pretty well.
- pretty big secret
bridging the worlds
Monads.
http://fuckingmonads.com
Signals.
jensravens.de/series/functional-reactive-programming-in-swift/
Boxing and Optionals.
Throwing Errors.
Mapping Arrays and
Collections.
Type Safety.
Protocols and Facades.
combining ideas
idea 1
treating your user as an
interface
user interface
Recipe
Recipe
Recipe
Recipe
Recipe
protocol User {
func selectRecipe(recipies: [Recipe], completion:Recipe->Void)
}
user interface
Recipe
Recipe
Recipe
Recipe
Recipe
protocol User {
func selectRecipe(recipies: [Recipe], completion:Recipe?->Void)
}
user interface
Recipe
Recipe
Recipe
Recipe
Recipe
protocol User {
func selectSingle(collection: [Selectable], completion:Selectable?->Void)
}
user interface
Recipe
Recipe
Recipe
Recipe
Recipe
func downloadStuff(term: String, completion: Result<[Recipe]>->Void){
// networking and error handling
}
class UserSelection: UIViewController, User {
static func selectRecipe(presentingViewController: UIViewController)
(recipies: [Recipe], completion: Result<Recipe> -> Void) {
// present your view controller here and save the completion block
}
}
let searchVC = // your current vc
let textField = // the textfield used for typing
textField
.textSignal
.flatMap(downloadStuff)
.flatMap(UserSelection.selectRecipe(searchVC))
.next { recipe in
// do whatever you like
}
.error { error in
// something went wrong on the way
}
idea 2
facades via typedef
abstract servers
public typealias Headers = [String: String]
public typealias Environment = [String: AnyObject]
public typealias StatusCode = Int
public typealias Response = (StatusCode, Headers, ContentStreamable)
public typealias Swagable = Request throws -> Response
let HelloWorld: Swagable = { env in
return (200, [:], "Hello World")
}
idea 3
common behavior in
protocols
protocol Contextable {
func showContext(gestureRecognizer: UIGestureRecognizer)
func viewControllerForContext(context: Item) -> UIViewController?
func contextViewControllerForContext(context: Item) ->
UIViewController?
func contextForGestureRecognizer(gestureRecognizer:
UIGestureRecognizer) -> Item?
// the only required method
func contextForIndexPath(indexPath: NSIndexPath) -> Item?
}
extension Contextable {
func viewControllerForContext(context: Item) -> UIViewController?
{
return self as? UIViewController
}
func contextForGestureRecognizer(gestureRecognizer:
UIGestureRecognizer) -> Item? {
// find the clicked indexpath
}
}
extension ChannelViewController: Contextable {
@IBAction func triggerContext(gestureRecognizer:
UIGestureRecognizer) {
showContext(gestureRecognizer)
}
func contextForIndexPath(indexPath: NSIndexPath) -> Item? {
return dataSource.itemForIndexPath(indexPath)
}
}
These are just concepts.
They won’t hurt you, they
won’t take away your job.
It’s more out there than just
object oriented
programming.
object oriented programming
has a lot of hidden gems you
might not be aware of yet.
learning from
other plattforms
these are amazing times
to be a developer
do not just read about
your plattform
Hipster oriented programming (Mobilization Lodz 2015)
Hipster oriented programming (Mobilization Lodz 2015)
Hipster oriented programming (Mobilization Lodz 2015)
Hipster oriented programming (Mobilization Lodz 2015)
What’s .next()?
Functors, Applicatives
and Monads in Pictures.
http://adit.io/posts/2013-04-17-
functors,_applicatives,_and_monads_in_pictures.html
The Introduction to RP
you’ve been missing.
https://gist.github.com/staltz/868e7e9bc2a7b8c1f754
Imperative Programming In Swift (Graham Lee)
sicpers.info/2015/07/imperative-programming-in-swift/
Protocol-Oriented Programming in Objective-C
sicpers.info/2015/06/protocol-oriented-programming-in-
objective-c/
Mutable objects in immutable objects in object-oriented
programming in functional programming in Swift
sicpers.info/2015/06/mutable-objects-in-immutable-
objects-in-object-oriented-programming-in-functional-
programming-in-swift/
keep searching for
new frontiers
use the right tool
for the right job
Hipster oriented programming (Mobilization Lodz 2015)
Thank you.
@JensRavens
jensravens.de

More Related Content

What's hot (20)

PPSX
JS Fest 2018. Сергей Пузанков. E2E-тестирование фронтенда c Hermione
JSFestUA
 
PDF
Introduction to Elm
Rogerio Chaves
 
PPT
A Deeper look into Javascript Basics
Mindfire Solutions
 
PPT
POLITEKNIK MALAYSIA
Aiman Hud
 
PDF
How much performance can you get out of Javascript? - Massimiliano Mantione -...
Codemotion
 
PDF
From Java to Kotlin - The first month in practice
StefanTomm
 
PDF
What To Expect From PHP7
Codemotion
 
PDF
An Introduction to Reactive Cocoa
SmartLogic
 
PDF
You do not need automation engineer - Sqa Days - 2015 - EN
Iakiv Kramarenko
 
PPT
JavaScript Basics
Mats Bryntse
 
PDF
Voxxed Days Vilnius 2015 - Having fun with Javassist
Anton Arhipov
 
PDF
JavaScript in 2016
Codemotion
 
ODP
Lambda Chops - Recipes for Simpler, More Expressive Code
Ian Robertson
 
PDF
Elm kyivfprog 2015
Alexander Mostovenko
 
PDF
Callbacks, promises, generators - asynchronous javascript
Łukasz Kużyński
 
PDF
Core Java - Quiz Questions - Bug Hunt
CodeOps Technologies LLP
 
PDF
LINQ Inside
jeffz
 
PDF
Understanding Asynchronous JavaScript
jnewmanux
 
PDF
Javascript Promises/Q Library
async_io
 
PDF
Protocol-Oriented Programming in Swift
Oleksandr Stepanov
 
JS Fest 2018. Сергей Пузанков. E2E-тестирование фронтенда c Hermione
JSFestUA
 
Introduction to Elm
Rogerio Chaves
 
A Deeper look into Javascript Basics
Mindfire Solutions
 
POLITEKNIK MALAYSIA
Aiman Hud
 
How much performance can you get out of Javascript? - Massimiliano Mantione -...
Codemotion
 
From Java to Kotlin - The first month in practice
StefanTomm
 
What To Expect From PHP7
Codemotion
 
An Introduction to Reactive Cocoa
SmartLogic
 
You do not need automation engineer - Sqa Days - 2015 - EN
Iakiv Kramarenko
 
JavaScript Basics
Mats Bryntse
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Anton Arhipov
 
JavaScript in 2016
Codemotion
 
Lambda Chops - Recipes for Simpler, More Expressive Code
Ian Robertson
 
Elm kyivfprog 2015
Alexander Mostovenko
 
Callbacks, promises, generators - asynchronous javascript
Łukasz Kużyński
 
Core Java - Quiz Questions - Bug Hunt
CodeOps Technologies LLP
 
LINQ Inside
jeffz
 
Understanding Asynchronous JavaScript
jnewmanux
 
Javascript Promises/Q Library
async_io
 
Protocol-Oriented Programming in Swift
Oleksandr Stepanov
 

Similar to Hipster oriented programming (Mobilization Lodz 2015) (20)

PPT
React native
Mohammed El Rafie Tarabay
 
PDF
JSAnkara Swift v React Native
Muhammed Demirci
 
PDF
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
Codemotion
 
PPTX
Android development with Scala and SBT
Anton Yalyshev
 
PDF
QA Fest 2015. Яков Крамаренко. Polyglot automation
QAFest
 
PDF
Polyglot automation - QA Fest - 2015
Iakiv Kramarenko
 
PDF
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
jeffz
 
PPTX
Knowledge of Javascript
Samuel Abraham
 
PPT
Node.js: CAMTA Presentation
Rob Tweed
 
ODP
Node js
hazzaz
 
PDF
Android best practices
Jose Manuel Ortega Candel
 
PDF
Taming Core Data by Arek Holko, Macoscope
Macoscope
 
PDF
Exploring Clojurescript
Luke Donnet
 
PPTX
2. Design patterns. part #2
Leonid Maslov
 
PPTX
Intro to Reactive Thinking and RxJava 2
JollyRogers5
 
PDF
Play framework
Andrew Skiba
 
PPTX
RxJava2 Slides
YarikS
 
PDF
Programming Sideways: Asynchronous Techniques for Android
Emanuele Di Saverio
 
PDF
Short intro to scala and the play framework
Felipe
 
JSAnkara Swift v React Native
Muhammed Demirci
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
Codemotion
 
Android development with Scala and SBT
Anton Yalyshev
 
QA Fest 2015. Яков Крамаренко. Polyglot automation
QAFest
 
Polyglot automation - QA Fest - 2015
Iakiv Kramarenko
 
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
jeffz
 
Knowledge of Javascript
Samuel Abraham
 
Node.js: CAMTA Presentation
Rob Tweed
 
Node js
hazzaz
 
Android best practices
Jose Manuel Ortega Candel
 
Taming Core Data by Arek Holko, Macoscope
Macoscope
 
Exploring Clojurescript
Luke Donnet
 
2. Design patterns. part #2
Leonid Maslov
 
Intro to Reactive Thinking and RxJava 2
JollyRogers5
 
Play framework
Andrew Skiba
 
RxJava2 Slides
YarikS
 
Programming Sideways: Asynchronous Techniques for Android
Emanuele Di Saverio
 
Short intro to scala and the play framework
Felipe
 
Ad

More from Jens Ravens (7)

PDF
Turning it up to 11 - Scaling Ruby on Rails to 100k rps
Jens Ravens
 
PDF
Server Side Swift - AppBuilders 2017
Jens Ravens
 
PDF
Working with Xcode and Swift Package Manager
Jens Ravens
 
PDF
Server Side Swift with Swag
Jens Ravens
 
PDF
Taming Asynchronous Transforms with Interstellar
Jens Ravens
 
PDF
Swift 2
Jens Ravens
 
PDF
Swift: Immutability and You
Jens Ravens
 
Turning it up to 11 - Scaling Ruby on Rails to 100k rps
Jens Ravens
 
Server Side Swift - AppBuilders 2017
Jens Ravens
 
Working with Xcode and Swift Package Manager
Jens Ravens
 
Server Side Swift with Swag
Jens Ravens
 
Taming Asynchronous Transforms with Interstellar
Jens Ravens
 
Swift 2
Jens Ravens
 
Swift: Immutability and You
Jens Ravens
 
Ad

Recently uploaded (20)

PPTX
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
PDF
NPD Software -Omnex systems
omnex systems
 
PPTX
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PPTX
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
PDF
Latest Capcut Pro 5.9.0 Crack Version For PC {Fully 2025
utfefguu
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
PDF
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
NPD Software -Omnex systems
omnex systems
 
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
Latest Capcut Pro 5.9.0 Crack Version For PC {Fully 2025
utfefguu
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 

Hipster oriented programming (Mobilization Lodz 2015)