Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Nieder mit dem Spaghetti Code durch Statemachines
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Nicolas Byl
April 25, 2018
Technology
0
150
Nieder mit dem Spaghetti Code durch Statemachines
Nicolas Byl
April 25, 2018
Tweet
Share
More Decks by Nicolas Byl
See All by Nicolas Byl
Platform Engineering ❤️ Developer Experience
nbyl
0
40
Die Flucht aus der Prototypen-Hölle
nbyl
0
52
Lean Prototyping for Industrial-IoT Projects
nbyl
0
71
DevSecOps - Vom Unikum zur gut geölten Maschine
nbyl
0
120
Securing your software supply chain
nbyl
0
380
Keeping-Up-WithUpstream.pdf
nbyl
0
180
Dr. Kube und der Helm - Anatomie einer CD-Pipeline
nbyl
0
140
Securing the "other" supply chain
nbyl
0
300
Kubernetes - Auf die Cluster, Fertig, Los!
nbyl
0
210
Other Decks in Technology
See All in Technology
スケーリングを封じられたEC2を救いたい
senseofunity129
0
100
AI時代のシステム開発者の仕事_20260328
sengtor
0
280
スピンアウト講座05_実践活用事例
overflowinc
0
1.3k
SSoT(Single Source of Truth)で「壊して再生」する設計
kawauso
2
370
ハーネスエンジニアリング×AI適応開発
aictokamiya
0
110
Phase09_自動化_仕組み化
overflowinc
0
1.8k
ADK + Gemini Enterprise で 外部 API 連携エージェント作るなら OAuth の仕組みを理解しておこう
kaz1437
0
210
Amazon Qはアマコネで頑張っています〜 Amazon Q in Connectについて〜
yama3133
1
140
PostgreSQL 18のNOT ENFORCEDな制約とDEFERRABLEの関係
yahonda
0
130
Physical AI on AWS リファレンスアーキテクチャ / Physical AI on AWS Reference Architecture
aws_shota
1
150
The essence of decision-making lies in primary data
kaminashi
0
110
俺の/私の最強アーキテクチャ決定戦開催 ― チームで新しいアーキテクチャに適合していくために / 20260322 Naoki Takahashi
shift_evolve
PRO
1
450
Featured
See All Featured
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
75
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
The browser strikes back
jonoalderson
0
850
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.4k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Designing Powerful Visuals for Engaging Learning
tmiket
0
300
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Amusing Abliteration
ianozsvald
0
140
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
410
The agentic SEO stack - context over prompts
schlessera
0
720
Transcript
1 NIEDER MIT DEM SPAGHETTI CODE DURCH STATEMACHINES JAX 2018
Nicolas Byl, codecentric AG
2 . 1 EINLEITUNG
None
2 . 2
2 . 3 2 . 4 Wer hat bereits eine
State Machine implementiert?
if (order.getState() == State.COMMISSIONED) { order.setState(State.SHIPPED); order.save(); }
2 . 5 2 . 6 Nochmal: Wer hat bereits
eine State Machine implementiert?
3 . 1 STATE MACHINES
3 . 2 Ein Beispiel Downloading docker pull Blocked docker
create Image is pulled Dependencies satisfied Pending Starting docker start Ready Throttling policy LivenessProbe reports its first OK Failed Time-out
3 . 3 Zustandsänderungen
3 . 4 DISTRIBUTED BALL OF MUD https://commons.wikimedia.org/wiki/File:Taylor%27s_Dorodango_cropped.jpg
3 . 5 Zustandsänderungen konzentrieren
4 . 1 SPRING STATE MACHINES
4 . 2 Spring State Machines State Machine Library Spring
Integration Event-basiert
4 . 3 Integration <dependencies> <dependency> <groupId>org.springframework.statemachine</groupId> <artifactId>spring-statemachine-core</artifactId> <version>1.2.8.RELEASE</version> </dependency>
</dependencies>
4 . 4 Konfiguration @Configuration @EnableStateMachine public class StateMachineConfig extends
EnumStateMachineConfigurerAda @Override public void configure(StateMachineStateConfigurer<CheckStatus, Ch states .withStates() .initial(CheckStatus.Initializing) .states(EnumSet.allOf(CheckStatus.class)); }
4 . 5 Konfiguration (2) @Override public void configure(StateMachineTransitionConfigurer<CheckStatu transitions
.withExternal() .source(CheckStatus.Initializing).target(CheckStatus. .and() .withExternal() .source(CheckStatus.Initializing).target(CheckStatus. .and() [...]; } }
4 . 6 Events auslösen stateMachine.sendEvent(CheckEvents.succeeded);
4 . 7 Zustandsänderungen überwachen @WithStateMachine static class MyBean {
@OnTransition(target = CheckStatus.Operational) void enteredOperational() { } @OnStateChanged public void checkStatusChanged(StateContext<CheckStatus, CheckEve } }
5 . 1 DEMO TIME
5 . 2 Monitoring Demo Monitoring von lokalen Dateien Alarmierung
wenn zwei Checks in Folge fehlschlagen
5 . 3 State Machine
5 . 4 Demo Project https://github.com/nbyl/spring-state-machine-demo
6 . 1 SPRING STATE MACHINE
6 . 2 Advanced Features Verteilte State Machines mittels Zookeeper
Scoping Security State Persistence
7 . 1 THE END Copyright 2018