More Related Content Similar to Develop Maintainable Apps (20) More from Annyce Davis (15) Develop Maintainable Apps1. Be a Good Citizen:
!
Develop Maintainable Apps
2. “…a high probability of determining the cause of
a problem in a timely manner… and a high
probability of being able to modify the program
without causing an error in some other part…”
— IEEE
24. So you need images…
Volley
!
Fresco
!
Glide
!
Picasso
!
59. Review…
• Keep Code Simple
• Use MV* Pattern
• Functional Tests
• Use the Tools
@brwngrldev
Domain
Design
2
66. apply plugin: ‘checkstyle’
!
task checkstyle(type: Checkstyle) {
description 'Checks if the code passes quality standards'
group 'verification'
configFile file(‘checkstyle.xml')
…
}
67. apply plugin: ‘checkstyle’
!
task checkstyle(type: Checkstyle) {
description 'Checks if the code passes quality standards'
group 'verification'
configFile file(‘checkstyle.xml')
…
}
70. <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
!
71. <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>
…
leable.WapoVideoView_showClosedCaptionsButton, false));
75. M = E − N + 2P
@brwngrldev
76. M = E − N + 2P
@brwngrldev
78. 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");
79. 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");
}
updateMetadata(video);
break;
…
81. 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;
82. 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;
83. 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
106. Review
• Listen to Robert Martin!
• JUnit + Mockito
• Continuous Integration
• Code Coverage
Testing
4
@brwngrldev
112. 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
• PostTV App - https://goo.gl/0TRsXU
@brwngrldev
113. Photo Credits
• Slide 4 - https://www.flickr.com/photos/nikigunn/8379494330
• Slide 6 - https://www.flickr.com/photos/tracy_olson/61056391
• Slide 7 - https://en.wikipedia.org/wiki/Dominoes
• Slide 10 - https://www.flickr.com/photos/tshirbert/118250140
• Slide 24 - http://uncompromisedmen.com/2015/02/17/top-10-crazy-beards-
wish-youd-seen-person/
• Slide 38 - https://www.flickr.com/photos/cast_fish/2888442781
• Slide 52 - https://www.flickr.com/photos/desertbusforhope/8207412726/
• Slide 54 - https://www.flickr.com/photos/sokabs/2668975758
• Slide 63 - https://www.flickr.com/photos/pasukaru76/5268559005
@brwngrldev