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

Platform Independent Architecture

HIFILEO
November 15, 2016

Platform Independent Architecture

A high level focus on how to architect a mobile application that can be supported on both iOS and Android. The talk is at a high level to try and get Android engineers and iOS engineers to work together. The realization is that MVP and VIPER are the exact same architectural patterns. With that understanding I discuss how software requirements and design patterns can be used before implementation can begin. The code snippets that show collaboration come from the NHL application which was first launched by MLB in Feb of 2016.

HIFILEO

November 15, 2016
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  PaFerns     •  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. 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...*/! }!
  4. /* 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());! }! }! !
  5. 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;! }! !
  6. @protocol  NHLSetupContextDelegate  <NSObject>   -­‐  (void)willTransitionFromState:(NHLSetupState  *)fromState   toState:(NHLSetupState  *)toState;

          @implementation  NHLSetupContext           -­‐  (void)setCurrentState:(NHLSetupState  *)currentState  {      _currentState  =  currentState;      /*Callbacks  Handled  Here*/   }       /*Additional Code...*/!   @end    
  7. /* 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];   }  
  8. Wrap  Up   •  It  all  starts  with  Business  Requirements

        •  Let’s  get  clean  with  ‘Clean  Code’   •  MVP  /  Viper  Base  PaFerns     •  NHL  Example