开发者

Are programming practices such as unit testing and logging important on android?

I am a university student. I have been working a lot with Android lately on my own time, and I cannot help but to feel that what I’v开发者_StackOverflow社区e been taught about good programming practices such as the importance of logging and writing unit tests don’t hold true.

The reason I am saying this is because Android apps are usually small apps that are not complex (a couple of activities, maybe a service, and perhaps a few other classes). Therefore, the effort and time spent on these ‘good practices’ don’t produce much better code.

In other words, I understand the importance of these practices when developing applications with large amount of classes, but when it comes to android apps, I find it much better to just write ‘not-so-good’ code and then just test by actually using the app on my own time on real devices for a few days or weeks.

Am I wrong about this? Why?


Unit Testing and Logging are most definitely still important on Android (or any other small applications).

The benefits are still there (your code is going to be better quality and you can automate the testing much more easily).

If you go by your original logic, when are you going to draw the line between "good practices" and the "test via the app as you go" strategy?

The line gets blurred and it's easy to start leaning towards the "easier" way of test as you go which will eventually lead to a large and complex application that was not properly designed with flexibility/testability in mind.


Unit testing will save you a lot of time you spend when you recompile your code and reinstall the application to emulator and rerun your application, so unit testing is good anyway.

Logging is also important because you can't test your application on all devices your application will run, there are too much of them. So, if something bad happened, you would have an ability to clarify what went wrong.


Unit testing is great. If at all possible, implement unit tests. It's a great first check anytime you make some substantial changes to your application. Probably not the best example of it, but I use unit testing in my open source app.

Logging is also very useful for when a bug comes up that you can't reproduce. A lot of users are very willing to submit logs to you.... But you have to do some logging to take advantage of this!


Please don't take this wrong but I can't help think that you're writing from the vantage point of a student who has only ever written class exercises and never written any "real world" apps. Any app worth loading on my Android device is quite complex and has at least thousands of lines of code; an environment that definitely benefits from Unit Tests and logging.

Jack Holt

Developer of Reveal Reader for Android, Gospel Library and ZapMe.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜