This is the "Basically Redux" talk that Cody gave at Android Listeners in May 2018. This talk goes over what Redux is along with some of the other relevant information and how it can be used on Android and clean up RxJava.
Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version)Tobias Pfeiffer
This is the Polyconf version of the talk, including a little MJIT vs. GraalVM rebuttal, JavaScript, SQL, Ruby and Elixir to be truly Poly.
“What’s the fastest way of doing this?” - you might ask yourself during development. Sure, you can guess, your intuition might be correct - but how do you know? Benchmarking is here to give you the answers, but there are many pitfalls in setting up a good benchmark and analyzing the results. This talk will guide you through, introduce best practices, and surprise you with some unexpected benchmarking results. You didn’t think that the order of arguments could influence its performance...or did you?
How fast is it really? Benchmarking in Practice (Ruby Version)Tobias Pfeiffer
“What’s the fastest way of doing this?” - you might ask yourself during development. Sure, you can guess what’s fastest or how long something will take, but do you know? How long does it take to sort a list of 1 Million elements? Are tail-recursive functions always the fastest?
Benchmarking is here to answer these questions. However, there are many pitfalls around setting up a good benchmark and interpreting the results. This talk will guide you through, introduce best practices and show you some surprising benchmarking results along the way.
Deze presentatie is gegeven tijdens de KScope conferentie 2012
Spreker: Luc Bors
Titel: How to Bring Common UI Patterns to ADF
Onderwerp: Fusion Middleware - Subonderwerp: ADF
Eindgebruikers van bedrijfsapplicaties eisen dezelfde gebruikerservaring die ze kennen van bijvoorbeeld office applicaties en applicaties op het internet. Functies zoals bookmarking, favorieten en het werken met tabs wordt graag gezien in de dagelijkse werk. Het zoekmechanisme van Google, dat suggesties toont op basis van de ingevoerde tekst, is zo ´gewoon´ dat mensen dit in elke applicatie terug willen zien. Twitter en Facebook geven automatisch aan dat je nieuwe berichten hebt zonder dat je daar zelf eerst om moet vragen, dat gebruikers de normaalste zaak van de wereld vinden. Er zijn nog veel meer van deze UI patterns. In deze sessie leer je hoe een aantal van deze UI patterns in je ADF applicatie kunt inbouwen waardoor de eindgebruiker beschikking krijgt over bekende en vanzelfsprekende features. Dit zal leiden tot een snellere acceptatie van de applicatie en prettigere gebruikerservaring.
When working with enterprise applications, you want to have the same user experience that you know from for instance office applications and browsers. People know how to use the features that can be found in browsers such as bookmarking, favorites, and working with tabs. The search mechanism provided by Google, that uses suggestions based on the text typed by the user, is so common that people expect this in every application. And there are more of these UI patterns. In this session, you will learn how to implement some of the common UI patterns in your ADF application.
Stop Guessing and Start Measuring - Benchmarking Practice (Poly Version)Tobias Pfeiffer
This is the Polyconf version of the talk, including a little MJIT vs. GraalVM rebuttal, JavaScript, SQL, Ruby and Elixir to be truly Poly.
“What’s the fastest way of doing this?” - you might ask yourself during development. Sure, you can guess, your intuition might be correct - but how do you know? Benchmarking is here to give you the answers, but there are many pitfalls in setting up a good benchmark and analyzing the results. This talk will guide you through, introduce best practices, and surprise you with some unexpected benchmarking results. You didn’t think that the order of arguments could influence its performance...or did you?
How fast is it really? Benchmarking in Practice (Ruby Version)Tobias Pfeiffer
“What’s the fastest way of doing this?” - you might ask yourself during development. Sure, you can guess what’s fastest or how long something will take, but do you know? How long does it take to sort a list of 1 Million elements? Are tail-recursive functions always the fastest?
Benchmarking is here to answer these questions. However, there are many pitfalls around setting up a good benchmark and interpreting the results. This talk will guide you through, introduce best practices and show you some surprising benchmarking results along the way.
Deze presentatie is gegeven tijdens de KScope conferentie 2012
Spreker: Luc Bors
Titel: How to Bring Common UI Patterns to ADF
Onderwerp: Fusion Middleware - Subonderwerp: ADF
Eindgebruikers van bedrijfsapplicaties eisen dezelfde gebruikerservaring die ze kennen van bijvoorbeeld office applicaties en applicaties op het internet. Functies zoals bookmarking, favorieten en het werken met tabs wordt graag gezien in de dagelijkse werk. Het zoekmechanisme van Google, dat suggesties toont op basis van de ingevoerde tekst, is zo ´gewoon´ dat mensen dit in elke applicatie terug willen zien. Twitter en Facebook geven automatisch aan dat je nieuwe berichten hebt zonder dat je daar zelf eerst om moet vragen, dat gebruikers de normaalste zaak van de wereld vinden. Er zijn nog veel meer van deze UI patterns. In deze sessie leer je hoe een aantal van deze UI patterns in je ADF applicatie kunt inbouwen waardoor de eindgebruiker beschikking krijgt over bekende en vanzelfsprekende features. Dit zal leiden tot een snellere acceptatie van de applicatie en prettigere gebruikerservaring.
When working with enterprise applications, you want to have the same user experience that you know from for instance office applications and browsers. People know how to use the features that can be found in browsers such as bookmarking, favorites, and working with tabs. The search mechanism provided by Google, that uses suggestions based on the text typed by the user, is so common that people expect this in every application. And there are more of these UI patterns. In this session, you will learn how to implement some of the common UI patterns in your ADF application.
At the time of writing, React hooks are still in alpha but they can already be used and, since it takes a while to get used to them, it's better to understand them as soon as possible. In this talk we will see some use cases in which we refactor a class component into a hook-based functional component.
How else can you write the code in PHP?Maksym Hopei
Usually we are limited with our environment and habits. When we make changes to a product or when we work with a team we follow the coding standards and the existing approaches to make our life and life of our teammates easier.
But often we do the same when we start a new product on our own ruled by our habits and by the limitations of our horizon.
This talk is intended to introduce some uncustomary ways to write code.
From the Java Collections Framework to the enhancements Groovy brings to the table when working with Collections. Based on https://tedvinke.wordpress.com/?s=Groovy+Weekend+Collections
Symfony World - Symfony components and design patternsŁukasz Chruściel
There are so many Symfony components already, and they have some pretty neat perks. But have you seen them in action?
Design patterns are not a silver bullet. They will never resolve your problem on their own. On the other hand, design patterns provide a common ground for developers without going into details and could be used as building bricks to solve some more advanced problems.
During my presentation, I will take a closer look and explain the appliance of selected design patterns. What is more, I will take advantage of the Symfony ecosystem to implement them with ease.
I will do the presentation on sample code that developers will understand at all levels of expertise.
Short (45 min) version of my 'Pragmatic Real-World Scala' talk. Discussing patterns and idioms discovered during 1.5 years of building a production system for finance; portfolio management and simulation.
At the time of writing, React hooks are still in alpha but they can already be used and, since it takes a while to get used to them, it's better to understand them as soon as possible. In this talk we will see some use cases in which we refactor a class component into a hook-based functional component.
How else can you write the code in PHP?Maksym Hopei
Usually we are limited with our environment and habits. When we make changes to a product or when we work with a team we follow the coding standards and the existing approaches to make our life and life of our teammates easier.
But often we do the same when we start a new product on our own ruled by our habits and by the limitations of our horizon.
This talk is intended to introduce some uncustomary ways to write code.
From the Java Collections Framework to the enhancements Groovy brings to the table when working with Collections. Based on https://tedvinke.wordpress.com/?s=Groovy+Weekend+Collections
Symfony World - Symfony components and design patternsŁukasz Chruściel
There are so many Symfony components already, and they have some pretty neat perks. But have you seen them in action?
Design patterns are not a silver bullet. They will never resolve your problem on their own. On the other hand, design patterns provide a common ground for developers without going into details and could be used as building bricks to solve some more advanced problems.
During my presentation, I will take a closer look and explain the appliance of selected design patterns. What is more, I will take advantage of the Symfony ecosystem to implement them with ease.
I will do the presentation on sample code that developers will understand at all levels of expertise.
Short (45 min) version of my 'Pragmatic Real-World Scala' talk. Discussing patterns and idioms discovered during 1.5 years of building a production system for finance; portfolio management and simulation.
Capability Driven Design - Andrzej Jóźwiak - TomTom Dev Day 2021Andrzej Jóźwiak
We are taught that the less dependencies a class has the better. So having a single dependency seems legit? Yes? No?
Unfortunately even a single dependency can corrupt a design. If our class only needs to select certain records why do we make it depend on the whole database? Wouldn't it be cool if we could make the class depend only on things it really needs?
Even control how it works with the dependencies or revoke the access if the need arises? Yes! This would be a nice thing!
During the talk we will learn how thinking about capabilities of our software will allow us to design code that will only allow users to do what is possible in that particular moment and how capabilities can make testing our software much much easier.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
3. @POTUS404Redux Basics
Actions
Actions are payloads of information that send
data from your application to your store. They
are the only source of information for the
store. Actions do not describe how the actions
will change the state.
https://redux.js.org/basics/actions
5. @POTUS404Redux Basics
Reducers
Reducers specify how the application's state
changes in response to actions sent to the
store. Remember that actions only describe
what happened, but don't describe how the
application's state changes.
https://redux.js.org/basics/reducers
6. @POTUS404Redux Basics
Reducers
function todoApp(state = initialState, action) {
switch (action.type) {
case SET_VISIBILITY_FILTER:
return Object.assign({}, state, {
visibilityFilter: action.filter
})
default:
return state
}
}
7. @POTUS404Redux Basics
The Store
The Store brings the actions and reducers
together. It holds the application’s state and
allows state to be updated and observed on.
You’ll only ever have one store in a Redux
application.
https://redux.js.org/basics/store
8. @POTUS404Redux Basics
Data Flow
Redux follows a strict unidirectional data flow.
This means data in your systems follows a
predictable path which is easier to
understand.
https://redux.js.org/basics/data-flow
14. @POTUS404Algebraic Data Types
Sum Type
sealed class GumballSize {
object Small : GumballSize()
object Medium : GumballSize()
object Large : GumballSize()
}
16. @POTUS404Pure Functions
Pure Functions
A pure function is a function where the return
value is only determined by its input values,
without observable side effects.
24. @POTUS404REDUCE!
fun main(args: Array<String>) {
val gumballMachine = GumballMachine()
while(true) {
if (gumballMachine.hasGumballs) {
println("Purchased a ${gumballMachine.buyGumball()}")
} else {
println("Sorry, no more gumballs.")
print("Would you like to refill the gumball machine? y/n: ")
if (readLine() == "y") {
gumballMachine.refill()
println()
} else {
return
}
}
}
}
Gumball Machine Usage
25. @POTUS404REDUCE!
fun main(args: Array<String>) {
val gumballMachine = GumballMachine()
while(true) {
if (gumballMachine.hasGumballs) {
println("Purchased a ${gumballMachine.buyGumball()}")
} else {
println("Sorry, no more gumballs.")
print("Would you like to refill the gumball machine? y/n: ")
if (readLine() == "y") {
gumballMachine.refill()
println()
} else {
return
}
}
}
}
Gumball Machine Usage
26. @POTUS404REDUCE!
fun main(args: Array<String>) {
val gumballMachine = GumballMachine()
while(true) {
if (gumballMachine.hasGumballs) {
println("Purchased a ${gumballMachine.buyGumball()}")
} else {
println("Sorry, no more gumballs.")
print("Would you like to refill the gumball machine? y/n: ")
if (readLine() == "y") {
gumballMachine.refill()
println()
} else {
return
}
}
}
}
Gumball Machine Usage
27. @POTUS404REDUCE!
fun main(args: Array<String>) {
val gumballMachine = GumballMachine()
while(true) {
if (gumballMachine.hasGumballs) {
println("Purchased a ${gumballMachine.buyGumball()}")
} else {
println("Sorry, no more gumballs.")
print("Would you like to refill the gumball machine? y/n: ")
if (readLine() == "y") {
gumballMachine.refill()
println()
} else {
return
}
}
}
}
Gumball Machine Usage
28. @POTUS404REDUCE!
fun main(args: Array<String>) {
val gumballMachine = GumballMachine()
while(true) {
if (gumballMachine.hasGumballs) {
println("Purchased a ${gumballMachine.buyGumball()}")
} else {
println("Sorry, no more gumballs.")
print("Would you like to refill the gumball machine? y/n: ")
if (readLine() == "y") {
gumballMachine.refill()
println()
} else {
return
}
}
}
}
Gumball Machine Usage
29. @POTUS404REDUCE!
The Gumball Machine
class GumballMachine(private val timeToDispense: Long = 50) {
object Gumball {
override fun toString() = "$color Gumball"
private val color
get() = when(Random().nextInt(8) + 1) {
1 -> "Blue"
2 -> "Red"
3 -> "Green"
4 -> "Yellow"
5 -> "Pink"
6 -> "Purple"
7 -> "Orange"
else -> "White"
}
}
val hasGumballs
get() = state.remainingGumballs > 0
private val gumballReducer = GumballReducer()
private var state = GumballState()
fun buyGumball(): Gumball {
state = gumballReducer.reduce(state, GumballAction.BuyGumball)
Thread.sleep(timeToDispense)
state = gumballReducer.reduce(state, GumballAction.Dispensed)
return Gumball
}
fun refill() {
state = gumballReducer.reduce(state, GumballAction.RefillGumballs)
}
}
30. @POTUS404REDUCE!
The Gumball Machine
class GumballMachine(private val timeToDispense: Long = 50) {
object Gumball {
override fun toString() = "$color Gumball"
private val color
get() = when(Random().nextInt(8) + 1) {
1 -> "Blue"
2 -> "Red"
3 -> "Green"
4 -> "Yellow"
5 -> "Pink"
6 -> "Purple"
7 -> "Orange"
else -> "White"
}
}
val hasGumballs
get() = state.remainingGumballs > 0
private val gumballReducer = GumballReducer()
private var state = GumballState()
fun buyGumball(): Gumball {
state = gumballReducer.reduce(state, GumballAction.BuyGumball)
Thread.sleep(timeToDispense)
state = gumballReducer.reduce(state, GumballAction.Dispensed)
return Gumball
}
fun refill() {
state = gumballReducer.reduce(state, GumballAction.RefillGumballs)
}
}
31. @POTUS404REDUCE!
The Gumball Machine
class GumballMachine(private val timeToDispense: Long = 50) {
object Gumball {
override fun toString() = "$color Gumball"
private val color
get() = when(Random().nextInt(8) + 1) {
1 -> "Blue"
2 -> "Red"
3 -> "Green"
4 -> "Yellow"
5 -> "Pink"
6 -> "Purple"
7 -> "Orange"
else -> "White"
}
}
32. @POTUS404REDUCE!
The Gumball Machine
class GumballMachine(private val timeToDispense: Long = 50) {
object Gumball {
override fun toString() = "$color Gumball"
private val color
get() = when(Random().nextInt(8) + 1) {
1 -> "Blue"
2 -> "Red"
3 -> "Green"
4 -> "Yellow"
5 -> "Pink"
6 -> "Purple"
7 -> "Orange"
else -> "White"
}
}
val hasGumballs
get() = state.remainingGumballs > 0
private val gumballReducer = GumballReducer()
private var state = GumballState()
fun buyGumball(): Gumball {
state = gumballReducer.reduce(state, GumballAction.BuyGumball)
Thread.sleep(timeToDispense)
state = gumballReducer.reduce(state, GumballAction.Dispensed)
return Gumball
}
fun refill() {
state = gumballReducer.reduce(state, GumballAction.RefillGumballs)
}
}
33. @POTUS404REDUCE!
The Gumball Machine
class GumballMachine(private val timeToDispense: Long = 50) {
object Gumball {
override fun toString() = "$color Gumball"
private val color
get() = when(Random().nextInt(8) + 1) {
1 -> "Blue"
2 -> "Red"
3 -> "Green"
4 -> "Yellow"
5 -> "Pink"
6 -> "Purple"
7 -> "Orange"
else -> "White"
}
}
val hasGumballs
get() = state.remainingGumballs > 0
private val gumballReducer = GumballReducer()
private var state = GumballState()
fun buyGumball(): Gumball {
state = gumballReducer.reduce(state, GumballAction.BuyGumball)
Thread.sleep(timeToDispense)
state = gumballReducer.reduce(state, GumballAction.Dispensed)
return Gumball
}
fun refill() {
state = gumballReducer.reduce(state, GumballAction.RefillGumballs)
}
}
34. @POTUS404REDUCE!
The Gumball Machine
class GumballMachine(private val timeToDispense: Long = 50) {
object Gumball {
override fun toString() = "$color Gumball"
private val color
get() = when(Random().nextInt(8) + 1) {
1 -> "Blue"
2 -> "Red"
3 -> "Green"
4 -> "Yellow"
5 -> "Pink"
6 -> "Purple"
7 -> "Orange"
else -> "White"
}
}
val hasGumballs
get() = state.remainingGumballs > 0
private val gumballReducer = GumballReducer()
private var state = GumballState()
fun buyGumball(): Gumball {
state = gumballReducer.reduce(state, GumballAction.BuyGumball)
Thread.sleep(timeToDispense)
state = gumballReducer.reduce(state, GumballAction.Dispensed)
return Gumball
}
fun refill() {
state = gumballReducer.reduce(state, GumballAction.RefillGumballs)
}
}
35. @POTUS404REDUCE!
The Gumball Machine
class GumballMachine(private val timeToDispense: Long = 50) {
object Gumball {
override fun toString() = "$color Gumball"
private val color
get() = when(Random().nextInt(8) + 1) {
1 -> "Blue"
2 -> "Red"
3 -> "Green"
4 -> "Yellow"
5 -> "Pink"
6 -> "Purple"
7 -> "Orange"
else -> "White"
}
}
val hasGumballs
get() = state.remainingGumballs > 0
private val gumballReducer = GumballReducer()
private var state = GumballState()
fun buyGumball(): Gumball {
state = gumballReducer.reduce(state, GumballAction.BuyGumball)
Thread.sleep(timeToDispense)
state = gumballReducer.reduce(state, GumballAction.Dispensed)
return Gumball
}
fun refill() {
state = gumballReducer.reduce(state, GumballAction.RefillGumballs)
}
}
36. @POTUS404REDUCE!
The Gumball Machine
class GumballMachine(private val timeToDispense: Long = 50) {
object Gumball {
override fun toString() = "$color Gumball"
private val color
get() = when(Random().nextInt(8) + 1) {
1 -> "Blue"
2 -> "Red"
3 -> "Green"
4 -> "Yellow"
5 -> "Pink"
6 -> "Purple"
7 -> "Orange"
else -> "White"
}
}
val hasGumballs
get() = state.remainingGumballs > 0
private val gumballReducer = GumballReducer()
private var state = GumballState()
fun buyGumball(): Gumball {
state = gumballReducer.reduce(state, GumballAction.BuyGumball)
Thread.sleep(timeToDispense)
state = gumballReducer.reduce(state, GumballAction.Dispensed)
return Gumball
}
fun refill() {
state = gumballReducer.reduce(state, GumballAction.RefillGumballs)
}
}
46. @POTUS404RxJava
Observable.fromPublisher<CompanyAction> { subscriber ->
0.until(320).map {
if (it % 11 == 0) CompanyAction.Add(Requisition.requisition) else CompanyAction.Hire(Requisition.requisition,
Employee.employee)
}.forEach { subscriber.onNext(it) }.also { subscriber.onComplete() }
}
.reduceWith({ Company("ActiveCampaign") }, { prevState, action ->
when(action) {
is CompanyAction.Hire -> {
val employees = prevState.employees.toMutableList()
employees.add(action.employee)
prevState.copy(employees = employees)
}
is CompanyAction.Add -> {
val requisitions = prevState.requisitions.toMutableList()
requisitions.add(action.requisition)
prevState.copy(requisitions = requisitions)
}
}
})
.subscribe { state ->
println("These numbers are most likely inaccurate.")
println("ActiveCampaign has ${state.requisitions.size} job openings with around ${state.employees.size} employees.")
println("There are ${state.employees.filter { it.name == "Cody" }.size} employees named Cody.")
println("Here is the raw state output:")
println(state)
}
47. @POTUS404RxJava
Observable.fromPublisher<CompanyAction> { subscriber ->
0.until(320).map {
if (it % 11 == 0) CompanyAction.Add(Requisition.requisition)
else CompanyAction.Hire(Requisition.requisition, Employee.employee)
}
.forEach { subscriber.onNext(it) }
.also { subscriber.onComplete() }
}
.reduceWith({ Company("ActiveCampaign") }, { prevState, action ->
when(action) {
is CompanyAction.Hire -> {
val employees = prevState.employees.toMutableList()
employees.add(action.employee)
prevState.copy(employees = employees)
}
is CompanyAction.Add -> {
val requisitions = prevState.requisitions.toMutableList()
requisitions.add(action.requisition)
prevState.copy(requisitions = requisitions)
}
}
})
.subscribe { state ->
println("These numbers are most likely inaccurate.")
println("ActiveCampaign has ${state.requisitions.size} job openings with around ${state.employees.size} employees.")
println("There are ${state.employees.filter { it.name == "Cody" }.size} employees named Cody.")
println("Here is the raw state output:")
println(state)
}
48. @POTUS404RxJava
Observable.fromPublisher<CompanyAction> { subscriber ->
0.until(320).map {
if (it % 11 == 0) CompanyAction.Add(Requisition.requisition) else CompanyAction.Hire(Requisition.requisition, Employee.employee)
}.forEach { subscriber.onNext(it) }.also { subscriber.onComplete() }
}
.reduceWith({ Company("ActiveCampaign") }, { prevState, action ->
when(action) {
is CompanyAction.Hire -> {
val employees = prevState.employees.toMutableList()
employees.add(action.employee)
prevState.copy(employees = employees)
}
is CompanyAction.Add -> {
val requisitions = prevState.requisitions.toMutableList()
requisitions.add(action.requisition)
prevState.copy(requisitions = requisitions)
}
}
})
.subscribe { state ->
println("These numbers are most likely inaccurate.")
println("ActiveCampaign has ${state.requisitions.size} job openings with around ${state.employees.size} employees.")
println("There are ${state.employees.filter { it.name == "Cody" }.size} employees named Cody.")
println("Here is the raw state output:")
println(state)
}
49. @POTUS404RxJava
Observable.fromPublisher<CompanyAction> { subscriber ->
0.until(320).map {
if (it % 11 == 0) CompanyAction.Add(Requisition.requisition) else CompanyAction.Hire(Requisition.requisition, Employee.employee)
}.forEach { subscriber.onNext(it) }.also { subscriber.onComplete() }
}
.reduceWith({ Company("ActiveCampaign") }, { prevState, action ->
when(action) {
is CompanyAction.Hire -> {
val employees = prevState.employees.toMutableList()
employees.add(action.employee)
prevState.copy(employees = employees)
}
is CompanyAction.Add -> {
val requisitions = prevState.requisitions.toMutableList()
requisitions.add(action.requisition)
prevState.copy(requisitions = requisitions)
}
}
})
.subscribe { state ->
println("These numbers are most likely inaccurate.")
println("ActiveCampaign has ${state.requisitions.size} job openings
with around ${state.employees.size} employees.")
println("There are ${state.employees.filter { it.name == "Cody" }.size}
employees named Cody.")
println("Here is the raw state output:")
println(state)
}
50. These numbers are most likely inaccurate.
ActiveCampaign has 30 job openings with around 290 employees.
There are 19 employees named Cody.
Here is the raw state output:
Company(name=ActiveCampaign,
requisitions=[Requisition(name=Full Stack Engineer, department=Engineering),
…)
@POTUS404RxJava