Excluding the “Historical Reasons” Factor in Android Mobile Projects. Continued

Excluding the “Historical Reasons” Factor in Android Mobile Projects. Continued

Time for part two of our article on Android Mobile Projects. Check it out.

Make a map of states

Your program is actually a set of states following one another. Make yours and others’ life easier — agree with the testing team on all possible states.

Use StateMachines, take everything into account, work on being prepared for what is expected, and be skeptical about external factors such as network failures or inadequate server responses — programmers work on them too, only back-end ones.

This will enable you to read your code as a set of theses and statements, not as lines of fiction based on a story line where you have to make decisions depending on dozens of factors — it doesn’t work that way. In one of my future posts I’ll give an example of finite state machine for Android.

The subscriber you are calling is...

Yes, it happens. Therefore develop your application taking into account that the network connection may fail at any time, and you’d better take it for granted: the connection will fail right now. 

So you will be prepared for the situation when you can’t send your order or make an http request.

Excluding_Android_Mobile_Projects_Continued_960.jpg


Let Dependency Injection in your project

First, you can split and parallelize the work. And perhaps continue the development while some components remain incomplete, you can make stubs on mock components. Besides, you can create mocks as if you have inadequate server response, and use all these riches both in tests and in the application. 

Dependency Injection provides you with infrastructure for tests without painful refactoring and experiments with implementations.  

Dagger 2 and Toothpick are excellent for that in an Android project.

Ivan, it’s too much water, but give us an example

This text might sound too popular, without excessive technical detail, but you can find a lot of articles about following certain patterns on the Internet. My task here is to point to actual problems and their consequences, and explain what they mean in real life.

As for examples, you can look at some concepts mentioned in this post here: http://github.com/vanatka/funwithinterfaces 

Unfortunately, life is a hard and to make it easier, one should follow the rules in order to avoid problems, and never make a compromise for immediate benefits.

Ivan Alyakskin
Lead Engineer
Mai ai întrebări?
Conectați-văcu noi