Android the Agile way

53
Android - A Practitioner's take on doing it The Agile Way Thiyagu, Krishna, Soundar, Ashwin

description

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

Transcript of Android the Agile way

Page 1: Android the Agile way

Android - A Practitioner's take on doing it The Agile Way

Thiyagu, Krishna, Soundar, Ashwin

Page 2: Android the Agile way

Can we run an Android Application Development Project the Agile Way?

Page 3: Android the Agile way

As a practitioner, what are the effects of the Technical Stack

on the process?

Page 4: Android the Agile way

How can I follow the 'Extreme Programming' Practices?

Page 5: Android the Agile way

As ThoughtWorks why can we expect Android Projects?

Page 6: Android the Agile way

Enterprises are looking for a Mobile Presence

Page 7: Android the Agile way

Mostly CRUD Applications though.

Page 8: Android the Agile way

Then Why a native app over a Web App?

Page 9: Android the Agile way

Native Applications are much more enabled than a web

application 

Page 10: Android the Agile way

etc.....

Page 11: Android the Agile way

But why Android?

Page 12: Android the Agile way

Steep increase in the user  base

Page 13: Android the Agile way

Lots of new Vendors

Page 14: Android the Agile way

So as ThoughtWorks, why have this capability?

Page 15: Android the Agile way

We want to build something cool !

Page 16: Android the Agile way

Disclaimer

Page 17: Android the Agile way

Why is this not just a Java Project?

Page 18: Android the Agile way

When you’re working with Android, it sure feels like you

are writing regular old standard Java SE code

Page 19: Android the Agile way

You are not!!

Page 20: Android the Agile way

So what is the difference?Its the runtime!!!!

Page 21: Android the Agile way

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.

Page 22: Android the Agile way

Dalvik is not even a Java Virtual Machine at all!

Page 23: Android the Agile way

It does not understand byte code. Instead...

Page 24: Android the Agile way

It understands Dex Code

Page 25: Android the Agile way

Everything you need as a programmer is available in the Dalvik implementation of Java

Page 26: Android the Agile way

Why do I mention all this?

Page 27: Android the Agile way

Because you might want to use something like JMock to

mock your dependencies when writing your unit tests

Page 28: Android the Agile way

Its not a full Java SE implementation

Page 29: Android the Agile way
Page 30: Android the Agile way

Test Driven Development

Page 31: Android the Agile way

The Application to be tested must/needs to run on a device

instance

Page 32: Android the Agile way

Any entity that aims to test the Android Application must be on

the device instance as well

Page 33: Android the Agile way

So the test in itself is Another Application!

Page 34: Android the Agile way

Android Testing and Instrumentation

Page 35: Android the Agile way

public class LoginActivity extends Activity     /* declarations of states*/        @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.login);             loginButton = (Button) findViewById(R.id.login_login_button);        usernameText = (TextView) findViewById(R.id.user_name_input);        passwordText = (TextView)findViewById(R.id.pass_word_input);        

        loginButton.setOnClickListener(new OnClickListener() {            public void onClick(View v) {                String username = usernameText.getText().toString();                String password = passwordText.getText().toString();                MyApplication.getLoginService().login(username, password);            }        });    }}

Page 36: Android the Agile way

public class LoginActivityTest extends ActivityUnitTestCase<LoginActivity> {    public LoginActivityTest() {         super(LoginActivity.class);    }     protected void setUp() throws Exception {

        super.setUp();        ...    }   /* Other tests for testing whether the button and text box exists*/    public void testOnClickOfLoginButtonItShouldSendUserNameAndPassWordToLoginServiceForVerifying(){        String userName = "rapidftr";        userNameEditText.setText(userName);        String passWord = "rapidftr";        passWordEditText.setText(passWord);         LoginService loginService = EasyMock.createMock(LoginService.class);        EasyMock.expect(loginService.login(userName, passWord)).andReturn(true);        EasyMock.replay(loginService);         RapidFTRApplication.setLoginService(loginService);                loginButton.performClick();                 EasyMock.verify(loginService);    }}

Page 37: Android the Agile way

Does the service Locator Pattern Seem like a bad idea?

Page 38: Android the Agile way

Ensure that your Mocking Framework is supported by the

Dalvik VM

Page 39: Android the Agile way

The problem with easy mock .... Mocking Concrete

Classes

Page 40: Android the Agile way

So can we clean up this mockery?

Page 41: Android the Agile way

Split the code into 2 types:1.Android Framework Dependent 2.Android Framework Independent

Page 42: Android the Agile way

Over Engineering the code is Dangerous.

Page 43: Android the Agile way

ActivityInstrumentationTestCase    

Page 44: Android the Agile way

Continuous Integration

Page 45: Android the Agile way

Android Debugger Bridge

adb install, -r, standup-timer-app.apk

Page 46: Android the Agile way

The Testing Application and the Application under test are deployed on the same device

instance

Page 47: Android the Agile way

Android Maven Plugin &Ant Script

  Android SDK Path

Platform UsedDevice Instance to use

Page 48: Android the Agile way

<plugin>                   <groupId>com.jayway.maven.plugins.android.generation2</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>

Page 49: Android the Agile way

Independent parts of the build

Page 50: Android the Agile way

    // start tracing to "/sdcard/calc.trace"    Debug.startMethodTracing("calc");    // ...    // stop tracing    Debug.stopMethodTracing();

Page 51: Android the Agile way
Page 52: Android the Agile way
Page 53: Android the Agile way

Time for Demo