SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
Software Engineering Large Practical

Common Java problems when coding for
Android and advice for dealing with them

                     Stephen Gilmore

        School of Informatics, University of Edinburgh


                  October 24th, 2012




                Stephen Gilmore   Software Engineering Large Practical
Java problems




   For some, developing for the Android platform might provide their
   first experience of working with a complex, modern Java API. This
   may test your knowledge of the Java programming language,
   especially with regard to features such as generics. The Android
   APIs make use of generics throughout and so you will have to
   know how to create and handle generic classes.




                        Stephen Gilmore   Software Engineering Large Practical
Raw types




  Raw types are a backwards compatibility feature which allowed
  new generic Java code to use old non-generic libraries and to allow
  non-generic Java code to continue to compile and work on modern
  Java versions. Raw types are not needed when working with the
  Android API and your project should not contain them.




                        Stephen Gilmore   Software Engineering Large Practical
Common Java problems: raw types, 8 warnings




                  Stephen Gilmore   Software Engineering Large Practical
Quick fix: a bad suggestion




                   Stephen Gilmore   Software Engineering Large Practical
Check the constructor documentation




                   Stephen Gilmore   Software Engineering Large Practical
Check the class documentation




                   Stephen Gilmore   Software Engineering Large Practical
What type of array are we adapting?




                   Stephen Gilmore   Software Engineering Large Practical
Type parameter added, 6 warnings




                   Stephen Gilmore   Software Engineering Large Practical
Raw type parameters




   Raw types need special treatment in method headers when
   instances of generic classes are being passed as parameters to
   methods. A special syntax is used to specify when we do not know
   the type of the parameter to the generic class.




                        Stephen Gilmore   Software Engineering Large Practical
Raw type in method header, 5 warnings




                   Stephen Gilmore   Software Engineering Large Practical
Consult the Java documentation




                   Stephen Gilmore   Software Engineering Large Practical
Adapter doesn’t work here




                   Stephen Gilmore   Software Engineering Large Practical
Adapter is an interface




                    Stephen Gilmore   Software Engineering Large Practical
T is not a class




                   Stephen Gilmore   Software Engineering Large Practical
Object: the goto class




                    Stephen Gilmore   Software Engineering Large Practical
T extends Adapter doesn’t work




                   Stephen Gilmore   Software Engineering Large Practical
“?” — the wild card parameter, 3 warnings




                   Stephen Gilmore   Software Engineering Large Practical
“Quick fix” would have worked here




                  Stephen Gilmore   Software Engineering Large Practical
Same result




              Stephen Gilmore   Software Engineering Large Practical
Working with the Java compiler



   The Java compiler used Eclipse allows you to tune the level of
   checking which your program receives during compilation. This
   checking (“static analysis”) evaluates the correctness of your
   program without executing it.

   The default settings do not apply particularly strict checking. We
   recommend tightening the default settings to detect errors in your
   Java code which you may otherwise miss.




                         Stephen Gilmore   Software Engineering Large Practical
Setting Java compiler preferences




                    Stephen Gilmore   Software Engineering Large Practical
Changing defaults




                    Stephen Gilmore   Software Engineering Large Practical
Potential programming problems




                  Stephen Gilmore   Software Engineering Large Practical
Tighter checking




                   Stephen Gilmore   Software Engineering Large Practical
Bug found




            Stephen Gilmore   Software Engineering Large Practical
Remembering and forgetting while developing




   Leaving an empty block is a classic “I must remember to do that
   later” error. By turning on stricter checking with the static
   analysis tools in the Java compiler we get automatic reminders in
   the form of Java problems. These will persist in our project until
   we do go back and write the remaining code block.




                         Stephen Gilmore   Software Engineering Large Practical
Logging




   As we have seen, the Android emulator occupies all of the screen
   real estate of our virtual device, in order to allow us to test apps as
   they will be used in practice. If we want to log informational
   messages for our own purposes then we should use the Android
   logging API.




                          Stephen Gilmore   Software Engineering Large Practical
Don’t forget to add logging . . .




ng
                          Stephen Gilmore   Software Engineering Large Practical

Contenu connexe

Tendances

Code Review
Code ReviewCode Review
Code Review
rantav
 
Code Review
Code ReviewCode Review
Code Review
Ravi Raj
 
Code-Review-Principles-Process-and-Tools (1)
Code-Review-Principles-Process-and-Tools (1)Code-Review-Principles-Process-and-Tools (1)
Code-Review-Principles-Process-and-Tools (1)
Aditya Bhuyan
 
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
VincitOy
 

Tendances (20)

Clean Software Design - DevNot Summit Istanbul 2017
Clean Software Design - DevNot Summit Istanbul 2017Clean Software Design - DevNot Summit Istanbul 2017
Clean Software Design - DevNot Summit Istanbul 2017
 
Scrum Events and Artifacts in Action
Scrum Events and Artifacts in ActionScrum Events and Artifacts in Action
Scrum Events and Artifacts in Action
 
Importance of the quality of code
Importance of the quality of codeImportance of the quality of code
Importance of the quality of code
 
Code Review
Code ReviewCode Review
Code Review
 
GDG Morgantown, WV: Write code you can depend on!
GDG Morgantown, WV: Write code you can depend on!GDG Morgantown, WV: Write code you can depend on!
GDG Morgantown, WV: Write code you can depend on!
 
DevOps & Technical Agility: From Theory to Practice
DevOps & Technical Agility: From Theory to PracticeDevOps & Technical Agility: From Theory to Practice
DevOps & Technical Agility: From Theory to Practice
 
Professional iOS development
Professional iOS developmentProfessional iOS development
Professional iOS development
 
MobSecCon 2015 - Dynamic Analysis of Android Apps
MobSecCon 2015 - Dynamic Analysis of Android AppsMobSecCon 2015 - Dynamic Analysis of Android Apps
MobSecCon 2015 - Dynamic Analysis of Android Apps
 
Test Driven Design - GDG DevFest Istanbul 2016
Test Driven Design - GDG DevFest Istanbul 2016Test Driven Design - GDG DevFest Istanbul 2016
Test Driven Design - GDG DevFest Istanbul 2016
 
Unwritten Manual for Pair Programming
Unwritten Manual for Pair ProgrammingUnwritten Manual for Pair Programming
Unwritten Manual for Pair Programming
 
Code Review
Code ReviewCode Review
Code Review
 
Global Day of Coderetreat'14 - Istanbul Event
Global Day of Coderetreat'14 - Istanbul EventGlobal Day of Coderetreat'14 - Istanbul Event
Global Day of Coderetreat'14 - Istanbul Event
 
Code-Review-Principles-Process-and-Tools (1)
Code-Review-Principles-Process-and-Tools (1)Code-Review-Principles-Process-and-Tools (1)
Code-Review-Principles-Process-and-Tools (1)
 
Beginning Android Development
Beginning Android DevelopmentBeginning Android Development
Beginning Android Development
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Peer Code Review An Agile Process
Peer Code Review An Agile ProcessPeer Code Review An Agile Process
Peer Code Review An Agile Process
 
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
 
Test Driven Development Part 1
Test Driven Development Part 1Test Driven Development Part 1
Test Driven Development Part 1
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 
Code Quality
Code QualityCode Quality
Code Quality
 

En vedette

Technical quiz conducted at EDC to Group-III Executives
Technical quiz conducted at EDC to Group-III ExecutivesTechnical quiz conducted at EDC to Group-III Executives
Technical quiz conducted at EDC to Group-III Executives
NTPC
 
IT Quiz Prelims
IT Quiz PrelimsIT Quiz Prelims
IT Quiz Prelims
Sonal Raj
 
Tech Quiz
Tech QuizTech Quiz
Tech Quiz
ssdcps8
 
General Quiz Prelims with Answers
General Quiz Prelims with AnswersGeneral Quiz Prelims with Answers
General Quiz Prelims with Answers
Quest-SGGSCC
 

En vedette (20)

Kraken '16 It quiz final
Kraken '16 It quiz finalKraken '16 It quiz final
Kraken '16 It quiz final
 
Quick quiz on Objective-C
Quick quiz on Objective-CQuick quiz on Objective-C
Quick quiz on Objective-C
 
Technical quiz conducted at EDC to Group-III Executives
Technical quiz conducted at EDC to Group-III ExecutivesTechnical quiz conducted at EDC to Group-III Executives
Technical quiz conducted at EDC to Group-III Executives
 
IT Quiz Final @ eRz eRDeN 15, IT Fest, ITM Mayyil
IT Quiz Final @ eRz eRDeN 15, IT Fest, ITM MayyilIT Quiz Final @ eRz eRDeN 15, IT Fest, ITM Mayyil
IT Quiz Final @ eRz eRDeN 15, IT Fest, ITM Mayyil
 
Tech quiz prelims
Tech quiz prelimsTech quiz prelims
Tech quiz prelims
 
Final Round Technical quiz at KMEA Engineering college by Electronics and com...
Final Round Technical quiz at KMEA Engineering college by Electronics and com...Final Round Technical quiz at KMEA Engineering college by Electronics and com...
Final Round Technical quiz at KMEA Engineering college by Electronics and com...
 
Technical Quiz KAINOTOMIA
Technical Quiz KAINOTOMIATechnical Quiz KAINOTOMIA
Technical Quiz KAINOTOMIA
 
Technical Quiz (Basic concepts of computers)
Technical Quiz (Basic concepts of computers)Technical Quiz (Basic concepts of computers)
Technical Quiz (Basic concepts of computers)
 
TCS IT WIZ 2013 Prelims Questions
TCS IT WIZ 2013 Prelims QuestionsTCS IT WIZ 2013 Prelims Questions
TCS IT WIZ 2013 Prelims Questions
 
Technical Quiz conducted at calicut on kerala state IT quiz
Technical Quiz conducted at calicut on kerala state IT quizTechnical Quiz conducted at calicut on kerala state IT quiz
Technical Quiz conducted at calicut on kerala state IT quiz
 
IT Quiz Prelims
IT Quiz PrelimsIT Quiz Prelims
IT Quiz Prelims
 
Galaxy 2014 General Quiz
Galaxy 2014 General QuizGalaxy 2014 General Quiz
Galaxy 2014 General Quiz
 
Tech Quiz
Tech QuizTech Quiz
Tech Quiz
 
General Quiz with answers
General Quiz with answersGeneral Quiz with answers
General Quiz with answers
 
IT Quiz
IT QuizIT Quiz
IT Quiz
 
Computer quiz for primary classes
Computer quiz for primary classesComputer quiz for primary classes
Computer quiz for primary classes
 
Gk quiz ppt avi
Gk quiz ppt aviGk quiz ppt avi
Gk quiz ppt avi
 
quiz,Junior quiz, inter house quiz, school quiz, quiz show,mixed bag, audio v...
quiz,Junior quiz, inter house quiz, school quiz, quiz show,mixed bag, audio v...quiz,Junior quiz, inter house quiz, school quiz, quiz show,mixed bag, audio v...
quiz,Junior quiz, inter house quiz, school quiz, quiz show,mixed bag, audio v...
 
Technology Quiz
Technology QuizTechnology Quiz
Technology Quiz
 
General Quiz Prelims with Answers
General Quiz Prelims with AnswersGeneral Quiz Prelims with Answers
General Quiz Prelims with Answers
 

Similaire à Common Java problems when developing with Android

Testing Android apps with Robotium
Testing Android apps with RobotiumTesting Android apps with Robotium
Testing Android apps with Robotium
Stephen Gilmore
 
javabasics_ programming development chapter01
javabasics_ programming development chapter01javabasics_ programming development chapter01
javabasics_ programming development chapter01
Udeshg90
 
Django strategy-test
Django strategy-testDjango strategy-test
Django strategy-test
Royce Haynes
 
Current Testing Challenges Ireland
Current Testing Challenges IrelandCurrent Testing Challenges Ireland
Current Testing Challenges Ireland
David O'Dowd
 

Similaire à Common Java problems when developing with Android (20)

SELP: Debugging, AVDs and Manifests
SELP: Debugging, AVDs and ManifestsSELP: Debugging, AVDs and Manifests
SELP: Debugging, AVDs and Manifests
 
Testing Android apps with Robotium
Testing Android apps with RobotiumTesting Android apps with Robotium
Testing Android apps with Robotium
 
Feedback on Part 1 of the Software Engineering Large Practical
Feedback on Part 1 of the Software Engineering Large PracticalFeedback on Part 1 of the Software Engineering Large Practical
Feedback on Part 1 of the Software Engineering Large Practical
 
javabasics_ programming development chapter01
javabasics_ programming development chapter01javabasics_ programming development chapter01
javabasics_ programming development chapter01
 
Working with databases in Android
Working with databases in AndroidWorking with databases in Android
Working with databases in Android
 
Different Techniques Of Debugging Selenium Based Test Scripts.pdf
Different Techniques Of Debugging Selenium Based Test Scripts.pdfDifferent Techniques Of Debugging Selenium Based Test Scripts.pdf
Different Techniques Of Debugging Selenium Based Test Scripts.pdf
 
Django strategy-test
Django strategy-testDjango strategy-test
Django strategy-test
 
Continuous Integration for Spark Apps by Sean McIntyre
Continuous Integration for Spark Apps by Sean McIntyreContinuous Integration for Spark Apps by Sean McIntyre
Continuous Integration for Spark Apps by Sean McIntyre
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
 
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
 
Bug hunting through_reverse_engineering
Bug hunting through_reverse_engineeringBug hunting through_reverse_engineering
Bug hunting through_reverse_engineering
 
End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
 
Jdj Foss Java Tools
Jdj Foss Java ToolsJdj Foss Java Tools
Jdj Foss Java Tools
 
Java Programming 100 Programming Challenges
Java Programming 100 Programming ChallengesJava Programming 100 Programming Challenges
Java Programming 100 Programming Challenges
 
Dagger 2
Dagger 2Dagger 2
Dagger 2
 
Android Dev Study Jam.pptx
Android Dev Study Jam.pptxAndroid Dev Study Jam.pptx
Android Dev Study Jam.pptx
 
Janet Gregory presents Current Testing Challenges with SoftTest Ireland
Janet Gregory presents Current Testing Challenges with SoftTest IrelandJanet Gregory presents Current Testing Challenges with SoftTest Ireland
Janet Gregory presents Current Testing Challenges with SoftTest Ireland
 
Current Testing Challenges Ireland
Current Testing Challenges IrelandCurrent Testing Challenges Ireland
Current Testing Challenges Ireland
 
Client Side Unit Testing
Client Side Unit TestingClient Side Unit Testing
Client Side Unit Testing
 

Plus de Stephen Gilmore

More Stochastic Simulation Examples
More Stochastic Simulation ExamplesMore Stochastic Simulation Examples
More Stochastic Simulation Examples
Stephen Gilmore
 
Fixing errors in Android Java applications
Fixing errors in Android Java applicationsFixing errors in Android Java applications
Fixing errors in Android Java applications
Stephen Gilmore
 
Continuing Android development
Continuing Android developmentContinuing Android development
Continuing Android development
Stephen Gilmore
 
Project management for the individual practical
Project management for the individual practicalProject management for the individual practical
Project management for the individual practical
Stephen Gilmore
 
Beginning Android development
Beginning Android developmentBeginning Android development
Beginning Android development
Stephen Gilmore
 
CS/SE Individual practical - DDMS and AVD
CS/SE Individual practical - DDMS and AVDCS/SE Individual practical - DDMS and AVD
CS/SE Individual practical - DDMS and AVD
Stephen Gilmore
 

Plus de Stephen Gilmore (16)

Feedback on Part 1 of the CSLP
Feedback on Part 1 of the CSLPFeedback on Part 1 of the CSLP
Feedback on Part 1 of the CSLP
 
Arrays in Objective-C
Arrays in Objective-CArrays in Objective-C
Arrays in Objective-C
 
More Stochastic Simulation Examples
More Stochastic Simulation ExamplesMore Stochastic Simulation Examples
More Stochastic Simulation Examples
 
Getting started with Xcode
Getting started with XcodeGetting started with Xcode
Getting started with Xcode
 
Crash Course in Objective-C
Crash Course in Objective-CCrash Course in Objective-C
Crash Course in Objective-C
 
The Stochastic Simulation Algorithm
The Stochastic Simulation AlgorithmThe Stochastic Simulation Algorithm
The Stochastic Simulation Algorithm
 
Computer Science Large Practical coursework
Computer Science Large Practical courseworkComputer Science Large Practical coursework
Computer Science Large Practical coursework
 
Software Engineering Large Practical coursework
Software Engineering Large Practical courseworkSoftware Engineering Large Practical coursework
Software Engineering Large Practical coursework
 
Introduction to the CSLP and the SELP
Introduction to the CSLP and the SELPIntroduction to the CSLP and the SELP
Introduction to the CSLP and the SELP
 
Fixing errors in Android Java applications
Fixing errors in Android Java applicationsFixing errors in Android Java applications
Fixing errors in Android Java applications
 
Feedback on Part 1 of the Individual Practical
Feedback on Part 1 of the Individual PracticalFeedback on Part 1 of the Individual Practical
Feedback on Part 1 of the Individual Practical
 
Creating and working with databases in Android
Creating and working with databases in AndroidCreating and working with databases in Android
Creating and working with databases in Android
 
Continuing Android development
Continuing Android developmentContinuing Android development
Continuing Android development
 
Project management for the individual practical
Project management for the individual practicalProject management for the individual practical
Project management for the individual practical
 
Beginning Android development
Beginning Android developmentBeginning Android development
Beginning Android development
 
CS/SE Individual practical - DDMS and AVD
CS/SE Individual practical - DDMS and AVDCS/SE Individual practical - DDMS and AVD
CS/SE Individual practical - DDMS and AVD
 

Dernier

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Dernier (20)

Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Common Java problems when developing with Android

  • 1. Software Engineering Large Practical Common Java problems when coding for Android and advice for dealing with them Stephen Gilmore School of Informatics, University of Edinburgh October 24th, 2012 Stephen Gilmore Software Engineering Large Practical
  • 2. Java problems For some, developing for the Android platform might provide their first experience of working with a complex, modern Java API. This may test your knowledge of the Java programming language, especially with regard to features such as generics. The Android APIs make use of generics throughout and so you will have to know how to create and handle generic classes. Stephen Gilmore Software Engineering Large Practical
  • 3. Raw types Raw types are a backwards compatibility feature which allowed new generic Java code to use old non-generic libraries and to allow non-generic Java code to continue to compile and work on modern Java versions. Raw types are not needed when working with the Android API and your project should not contain them. Stephen Gilmore Software Engineering Large Practical
  • 4. Common Java problems: raw types, 8 warnings Stephen Gilmore Software Engineering Large Practical
  • 5. Quick fix: a bad suggestion Stephen Gilmore Software Engineering Large Practical
  • 6. Check the constructor documentation Stephen Gilmore Software Engineering Large Practical
  • 7. Check the class documentation Stephen Gilmore Software Engineering Large Practical
  • 8. What type of array are we adapting? Stephen Gilmore Software Engineering Large Practical
  • 9. Type parameter added, 6 warnings Stephen Gilmore Software Engineering Large Practical
  • 10. Raw type parameters Raw types need special treatment in method headers when instances of generic classes are being passed as parameters to methods. A special syntax is used to specify when we do not know the type of the parameter to the generic class. Stephen Gilmore Software Engineering Large Practical
  • 11. Raw type in method header, 5 warnings Stephen Gilmore Software Engineering Large Practical
  • 12. Consult the Java documentation Stephen Gilmore Software Engineering Large Practical
  • 13. Adapter doesn’t work here Stephen Gilmore Software Engineering Large Practical
  • 14. Adapter is an interface Stephen Gilmore Software Engineering Large Practical
  • 15. T is not a class Stephen Gilmore Software Engineering Large Practical
  • 16. Object: the goto class Stephen Gilmore Software Engineering Large Practical
  • 17. T extends Adapter doesn’t work Stephen Gilmore Software Engineering Large Practical
  • 18. “?” — the wild card parameter, 3 warnings Stephen Gilmore Software Engineering Large Practical
  • 19. “Quick fix” would have worked here Stephen Gilmore Software Engineering Large Practical
  • 20. Same result Stephen Gilmore Software Engineering Large Practical
  • 21. Working with the Java compiler The Java compiler used Eclipse allows you to tune the level of checking which your program receives during compilation. This checking (“static analysis”) evaluates the correctness of your program without executing it. The default settings do not apply particularly strict checking. We recommend tightening the default settings to detect errors in your Java code which you may otherwise miss. Stephen Gilmore Software Engineering Large Practical
  • 22. Setting Java compiler preferences Stephen Gilmore Software Engineering Large Practical
  • 23. Changing defaults Stephen Gilmore Software Engineering Large Practical
  • 24. Potential programming problems Stephen Gilmore Software Engineering Large Practical
  • 25. Tighter checking Stephen Gilmore Software Engineering Large Practical
  • 26. Bug found Stephen Gilmore Software Engineering Large Practical
  • 27. Remembering and forgetting while developing Leaving an empty block is a classic “I must remember to do that later” error. By turning on stricter checking with the static analysis tools in the Java compiler we get automatic reminders in the form of Java problems. These will persist in our project until we do go back and write the remaining code block. Stephen Gilmore Software Engineering Large Practical
  • 28. Logging As we have seen, the Android emulator occupies all of the screen real estate of our virtual device, in order to allow us to test apps as they will be used in practice. If we want to log informational messages for our own purposes then we should use the Android logging API. Stephen Gilmore Software Engineering Large Practical
  • 29. Don’t forget to add logging . . . ng Stephen Gilmore Software Engineering Large Practical