Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nieder mit dem Spaghetti Code durch Statemachines

Nieder mit dem Spaghetti Code durch Statemachines

Nicolas Byl

April 25, 2018

Transcript

26 slides
  1. 2 . 3 2 . 4 Wer hat bereits eine

    State Machine implementiert?
  2. 2 . 5 2 . 6 Nochmal: Wer hat bereits

    eine State Machine implementiert?
  3. 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
  4. 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)); }
  5. 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() [...]; } }
  6. 4 . 7 Zustandsänderungen überwachen @WithStateMachine static class MyBean {

    @OnTransition(target = CheckStatus.Operational) void enteredOperational() { } @OnStateChanged public void checkStatusChanged(StateContext<CheckStatus, CheckEve } }

More Decks by Nicolas Byl

Other Decks in Technology