Mais conteúdo relacionado Semelhante a Develop Maintainable Apps - edUiConf (20) Mais de Annyce Davis (13) Develop Maintainable Apps - edUiConf9. So you need images…
Volley
!
Fresco
!
Glide
!
Picasso
!
33. Review…
• Keep Code Simple
• Use MV* Pattern
• Functional Tests
• Use the Tools
@brwngrldev
Domain
Design
2
38. apply plugin: ‘checkstyle’
task checkstyle(type: Checkstyle) {
description 'Checks if the code passes quality standards'
group 'verification'
configFile file(‘checkstyle.xml')
…
}
39. <module name=“MethodLength">
<property name="max" value=“60"/>
</module>
<module name=“LineLength">
<property name="max" value=“120"/>
</module>
<module name=“CyclomaticComplexity">
<property name="max" value=“8"/>
</module>
…
playerControlConfig.setShowClosedCaptionsButton(a.getBo
42. public void overlyComplexMethod(Video video) {
if (video != null && video.getStreamUrl() != null) {
switch (video.getCategory()) {
case "CAT1" :
playVideo(video);
if (video.getLargeImageUrl() == null) {
video.setLargeImageUrl("http://www.largeImage.png");
}
updateMetadata(video);
break;
case "CAT2" :
if (video.getLargeImageUrl() == null) {
video.setLargeImageUrl("http://www.smallImage.png");
44. public void overlyComplexMethod(Video video) {
if (video != null && video.getStreamUrl() != null) {
updateVideoBasedOnCategory(video);
}
}
private void updateVideoBasedOnCategory(Video video) {
switch (video.getCategory()) {
case "CAT1" :
playVideo(video);
if (video.getLargeImageUrl() == null) {
video.setLargeImageUrl("http://www.largeImage.png");
}
updateMetadata(video);
break;
7
53. JUnit
• Framework for writing repeatable tests
• Assertions for testing expected results
• Features for sharing common test data
• Test suites for organizing tests
54. Mockito
• Enables mock creation and verification
• Mock concrete classes and interfaces
• Simple annotation support
60. Sample Test
@brwngrldev
@Test
public void configurationLoaded_shouldHideSplashScreen ()
{
ConfigurationLoadedEvent event = new ConfigurationLoadedEvent();
mainPresenter.onEvent( event );
verify( mainView ).hideSplashScreen();
}
65. Review
• Listen to Robert Martin!
• JUnit + Mockito
• Continuous Integration
• Code Coverage
Testing
4
@brwngrldev
68. Resources
• Clean Code - http://amzn.to/1DJybxH
• Effective Java - http://amzn.to/1Ku8Xel
• Working Effectively with Legacy Code - http://amzn.to/1Jqe1PA
• Unit Testing Idioms - http://goo.gl/Bx1WbL
• Google Code Style - http://goo.gl/8Pf6J3
• Architecting Android - http://goo.gl/UKvmbq
• Conquering Cyclomatic Complexity - http://goo.gl/lRoPXN
@brwngrldev
69. Photo Credits
• Slide 5 - https://www.flickr.com/photos/tshirbert/118250140
• Slide 19 - http://uncompromisedmen.com/2015/02/17/top-10-crazy-beards-
wish-youd-seen-person/
• Slide 34 - https://www.flickr.com/photos/cast_fish/2888442781
• Slide 48 - https://www.flickr.com/photos/desertbusforhope/8207412726/
• Slide 50 - https://www.flickr.com/photos/sokabs/2668975758
• Slide 64 - https://www.flickr.com/photos/pasukaru76/5268559005
@brwngrldev