Bartolomeo Sorrentino
He is a Principal Software Architect with over 25 years of experience. He is an active contributor to the open source ecosystem. He leads several OS projects and contributes to many others.
A Software Architect with over 25 years of experience.
CTO in Softphone and Cofounder of SoulSofware company.
an active contributor to the open source eco-system. https://github.com/bsorrentino
http://soulsoftware-bsc.blogspot.it/
https://twitter.com/bsorrentinoJ
Published in 2014 the Reactive manifesto refers to Reactive System as system that are more flexible, loosely-coupled and scalable.
Such system must be:
The Reactive Manifesto introduces a
"tech. agnostic shared vocabulary"
that will help us to better understand the concepts that we will meet during our knowledge acquisition path:
The main terms are:
and gets ....
...... BLA, BLA, BLA ..........
programming
PARADIGM !!!
yet
Another
searchResultsUpdatingSubject
.filter( { (filter:String) -> Bool in
return filter.characters.count > 2
})
.distinctUntilChanged()
.debounce(debounce, scheduler: MainScheduler.instance)
.flatMap( { (filterString) -> Observable<NSData> in
return slideshareSearch( apiKey: credentials["apiKey"],
sharedSecret: credentials["sharedSecret"],
what: filterString )
})
.flatMap({ (data:NSData) -> Observable<Slideshow> in
self.filteredDataItems.removeAll()
let slidehareItemsParser = SlideshareItemsParser()
return slidehareItemsParser.rx_parse(data)
})
.filter({ (slide:Slideshow) -> Bool in
if let format = slide["format"] {
return format.lowercaseString=="pdf";
}
return true
})
.observeOn(MainScheduler.instance)
.subscribe({ e in
if let slide = e.element {
self.filteredDataItems.append(slide)
let title = slide["title"]
self.collectionView?.reloadData()
}
}).addDisposableTo(disposeBag)
To Be Reactive ... never block
More in general in every User Interaction based Application
Achieve Seamlessly Vertical & Horizontal Scalability
I’ve heard a good argument about when to use reactive programming to develop solutions
They say ...
under a certain level of complexity in the code, reactive makes it even more complex, but after a point, it makes complex code simpler.
Path toward RFP
start to Develop:
1) Fluently
(use Builder Pattern)
2) Fluently + Functional
(use and abuse of lamdba)
3) Fluently + Functional + Asynchronous
(use MessageLoop and Scheduler)
Adopt Reactive Programming means developing using asynchronous data stream
The closer concept to asynchronous data stream is
"Iterate on collection over time"
But, since we have deal with time dimension, in Reactive Programming instead of "Iterate over data" we have to "Observe for event"
The effectiveness of Reactive Programming depends by ability to create streams of anything: variables, user inputs, properties, caches, data structures, network & system events, etc.
Here the famous design patterns that everyone known .
but not always everyone apply
Here the only patterns need to be reactive:
Iterator:
To iterate over data in one way
Observer:
To handle and process data
Builder:
To achieve fluently and expressive code
Reactive Programming is an improved alternative to the Observer Pattern that's designed to deal with events as a stream of values over time rather than as a series of unique responses to discrete changes in state.
This helps to deal with complex logic behind the event handling code with no loss of expressiveness.
It is useful anywhere the Observer pattern is common, including user interfaces, video games, networking, and industrial applications.
Iterable | Observable |
---|---|
Pull | Push |
T next() | onNext(T) |
Throws E | OnError(E) |
return | onCompleted() |
I have a Stream
The Marble Diagram
A great way to represent stream processing
From Sequence to Marble Diagrams
The Core of the RX that enable stream processing through function composition
You have to know how properly applying them to achieve the powerful of RX
Transforming — Operators that transform items that are emitted by an Observable.
Filtering — Operators that selectively emit items from a source Observable.
Combining — Operators that work with multiple source Observables to create a single Observable
Error Handling — Operators that help to recover from error notifications from an Observable
Observable Utility — A toolbox of useful Operators for working with Observables
Convert — Convert Observables into another objects or data structures
Most programmers exposes programming using term like: "triggering", "updating", "dispatching", "firing" methods and procedures.
Those are idioms and techniques opposite to reactive programming, where instead we try to declare what is "triggered by" or "updated by". (from message to event)
The biggest challenge is simply to go through the mental revolution from "A changes B" to "B is changed by A". After that, the smaller challenges are learning Rx operators, where they apply, and common techniques. >>
By Bartolomeo Sorrentino
The Reactive Systems require a development shift to write asynchronous APIs and Applications. Such shift has driven by "Reactive Programming"
He is a Principal Software Architect with over 25 years of experience. He is an active contributor to the open source ecosystem. He leads several OS projects and contributes to many others.