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

Platform Independent Architecture V2

HIFILEO
March 14, 2017

Platform Independent Architecture V2

Version 2 of a platform independent architecture talk I gave. The ending now has videos.

HIFILEO

March 14, 2017
Tweet

More Decks by HIFILEO

Other Decks in Education

Transcript

  1. Goal • It all starts with Business Requirements • Let’s

    get clean with ‘Clean Code’ • MVP / VIPER Base Patterns • NHL Example
  2. Requirements & Engineering • Business Requirements are Use Cases •

    Use Cases are Business Logic • An app’s business logic should be well defined and testable.
  3. MVC

  4. public class NHLSetupContext { private User user; private NHLSetupState nhlSetupState;

    private Set<SetupContextCallback> callbacks... public NHLSetupContext(User user) { this.user = user; setState(new NHLSetupStateSplash()); } void setState(final NHLSetupState state) { this.nhlSetupState = state; /*Callbacks Handled here...*/ } public void processMessage(final NHLSetupMessage message{ nhlSetupState.processMessage(this, message); } /*Additional Code...*/ }
  5. /* Base class for the setup state pattern*/ public abstract

    class NHLSetupState { public abstract void processMessage( final NHLSetupContext nhlSetupContext, final NHLSetupMessage nhlSetupMessage); } /* Represents the Splash screen state.*/ public class NHLSetupStateSplash extends NHLSetupState { @Override public void processMessage(NHLSetupContext nhlSetupContext, NHLSetupMessage nhlSetupMessage) { /* Do work… Determine Next State*/ /* Set Next State*/ nhlSetupContext.setState(new NHLSetupStateABC()); } }
  6. public class NHLSetupStateControllerSplashTest implements SetupContextCallback { private SetupState currentState; @Before

    public void setUp() throws Exception { /*Register Callback for State Machine*/ } @Test public void testSplashToABC() { //Setup State To Test .. //Perform Test nhlSetupContext.processMessage(/*Some Value*/); assertEquals(SetupState.ABC, currentState); } @Override public void transitionToState(SetupState setupState) { currentState = setupState; }
  7. @protocol NHLSetupContextDelegate <NSObject> - (void)willTransitionFromState:(NHLSetupState *)fromState toState:(NHLSetupState *)toState; @implementation NHLSetupContext

    - (void)setCurrentState:(NHLSetupState *)currentState { _currentState = currentState; /*Callbacks Handled Here*/ } /*Additional Code...*/ @end
  8. /* Base class for the setup state pattern*/ @implementation NHLSetupState

    // Stubs - (void)process {} /* Represents the Splash screen state.*/ @interface NHLSetupStateSplash : NHLSetupState @implementation NHLSetupStateSplash - (void)process { /* Do work… Determine Next State*/ /* Set Next State*/ self.context.currentState = [[NHLSetupStateABC alloc] initWithContext:self.context]; }
  9. NHL

  10. Wrap Up • It all starts with Business Requirements •

    Let’s get clean with ‘Clean Code’ • MVP / Viper Base Patterns • NHL & Arena Examples