Android the Agile way


Published on

Thiyagu, Krishna, Soundar and Ashwin presented at xconf on some tools that can help support extreme programming practices on a project based of the Android platform

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Android the Agile way

  1. 1. Android - A Practitioner's take on doing it The Agile Way Thiyagu, Krishna, Soundar, Ashwin
  2. 2. Can we run an Android Application Development Project the Agile Way?
  3. 3. As a practitioner, what are the effects of the Technical Stack on the process?
  4. 4. How can I follow the 'Extreme Programming' Practices?
  5. 5. As ThoughtWorks why can we expect Android Projects?
  6. 6. Enterprises are looking for a Mobile Presence
  7. 7. Mostly CRUD Applications though.
  8. 8. Then Why a native app over a Web App?
  9. 9. Native Applications are much more enabled than a web application 
  10. 10. etc.....
  11. 11. But why Android?
  12. 12. Steep increase in the user  base
  13. 13. Lots of new Vendors
  14. 14. So as ThoughtWorks, why have this capability?
  15. 15. We want to build something cool !
  16. 16. Disclaimer
  17. 17. Why is this not just a Java Project?
  18. 18. When you’re working with Android, it sure feels like you are writing regular old standard Java SE code
  19. 19. You are not!!
  20. 20. So what is the difference? Its the runtime!!!!
  21. 21. In the Android platform, we have the Dalvik Runtime which is specially designed for devices that are contrained in terms of memory, speed and battery power.
  22. 22. Dalvik is not even a Java Virtual Machine at all!
  23. 23. It does not understand byte code. Instead...
  24. 24. It understands Dex Code
  25. 25. Everything you need as a programmer is available in the Dalvik implementation of Java
  26. 26. Why do I mention all this?
  27. 27. Because you might want to use something like JMock to mock your dependencies when writing your unit tests
  28. 28. Its not a full Java SE implementation
  29. 30. Test Driven Development
  30. 31. The Application to be tested must/needs to run on a device instance
  31. 32. Any entity that aims to test the Android Application must be on the device instance as well
  32. 33. So the test in itself is Another Application!
  33. 34. Android Testing and Instrumentation
  34. 35. <ul><li>public class LoginActivity extends Activity  </li></ul><ul><li>     /* declarations of states*/     </li></ul><ul><li>     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.login);              loginButton = (Button) findViewById(;         usernameText = (TextView) findViewById(;         passwordText = (TextView)findViewById(;          </li></ul><ul><li>         loginButton.setOnClickListener(new OnClickListener() { </li></ul><ul><li>             public void onClick(View v) {                 String username = usernameText.getText().toString();                 String password = passwordText.getText().toString();                 MyApplication.getLoginService().login(username, password);             }         });     } } </li></ul>
  35. 36. <ul><li>public class LoginActivityTest extends ActivityUnitTestCase<LoginActivity> { </li></ul><ul><li>    public LoginActivityTest() { </li></ul><ul><li>        super(LoginActivity.class); </li></ul><ul><li>    } </li></ul><ul><li>  </li></ul><ul><li>    protected void setUp() throws Exception { </li></ul><ul><li>        super.setUp(); </li></ul><ul><li>        ... </li></ul><ul><li>    } </li></ul><ul><li>   /* Other tests for testing whether the button and text box exists*/  </li></ul><ul><li>   public void testOnClickOfLoginButtonItShouldSendUserNameAndPassWordToLoginServiceForVerifying() </li></ul><ul><li>{ </li></ul><ul><li>         String userName = &quot;rapidftr&quot;; </li></ul><ul><li>        userNameEditText.setText(userName); </li></ul><ul><li>         String passWord = &quot;rapidftr&quot;; </li></ul><ul><li>        passWordEditText.setText(passWord); </li></ul><ul><li>  </li></ul><ul><li>        LoginService loginService = EasyMock.createMock(LoginService.class); </li></ul><ul><li>        EasyMock.expect(loginService.login(userName, passWord)).andReturn(true); </li></ul><ul><li>        EasyMock.replay(loginService); </li></ul><ul><li>  </li></ul><ul><li>        RapidFTRApplication.setLoginService(loginService);        </li></ul><ul><li>  </li></ul><ul><li>        loginButton.performClick();        </li></ul><ul><li>  </li></ul><ul><li>        EasyMock.verify(loginService); </li></ul><ul><li>     } </li></ul><ul><li>} </li></ul>
  36. 37. Does the service Locator Pattern Seem like a bad idea?
  37. 38. Ensure that your Mocking Framework is supported by the Dalvik VM
  38. 39. The problem with easy mock .... Mocking Concrete Classes
  39. 40. So can we clean up this mockery?
  40. 41. Split the code into 2 types: 1.Android Framework Dependent  2.Android Framework Independent
  41. 42. Over Engineering the code is Dangerous.
  42. 43. ActivityInstrumentationTestCase    
  43. 44. Continuous Integration
  44. 45. Android Debugger Bridge adb install, -r, standup-timer-app.apk
  45. 46. The Testing Application and the Application under test are deployed on the same device instance
  46. 47. Android Maven Plugin  &Ant Script     Android SDK Path Platform Used Device Instance to use
  47. 48. <plugin>                    <groupId></groupId>                    <artifactId>maven-android-plugin</artifactId>                    <version>2.5.1</version>                    <configuration>                        <sdk>                             <path>android_sdk</path>                            <platform>7</platform>                        </sdk>                        <emulator>                            <avd>my_avd</avd>                        </emulator>                        <deleteConflictingFiles>                             true                        </deleteConflictingFiles>                        <undeployBeforeDeploy>true</undeployBeforeDeploy>                    </configuration>                    <extensions>true</extensions>    </plugin>
  48. 49. Independent parts of the build
  49. 50.     // start tracing to &quot;/sdcard/calc.trace&quot;     Debug.startMethodTracing(&quot;calc&quot;);     // ...     // stop tracing     Debug.stopMethodTracing();
  50. 53. Time for Demo