Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked...
Transcript of Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked...
![Page 1: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/1.jpg)
presentation
Java Programming – Software App Development Cristian Toma D.I.C.E/D.E.I.C – Department of Economic Informatics & Cybernetics www.dice.ase.ro
Lecture 5
summary of Java SE
![Page 2: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/2.jpg)
Cristian Toma – Business Card
![Page 3: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/3.jpg)
Agenda for Lecture 5 – Summary of JSE
Java
Exceptions
Source Code Design Patterns
Exchange Ideas
![Page 4: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/4.jpg)
Java Exceptions Exception mechanisms and features
![Page 5: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/5.jpg)
1.1 Java Exceptions Summary
Propagation Mode:
![Page 6: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/6.jpg)
1.1 Java Exceptions Summary
Exceptions Types:
1. checked exception
They are not passing by the compilation phase. May exist a “recovery”
mechanism but it is a MUST to have “try-catch” source code statements.
2. errors
They are passing by the compilation phase, BUT it is impossible to forecast
malfunctions of HW or OS – e.g. HDD has bad sectors and for opening a file
there is a ‘java.io.IOError’ throw. In practice, there is not a try-catch statement
for them.
3. runtime exception
They are passing by the compilation phase, BUT the development logics is not
implemented correct – e.g. after computations there is a «divison by zero». It is
possible to use try-catch mechanism but it is better to investigate and to correct
the «logic bug».
2+3 = unchecked exception
![Page 7: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/7.jpg)
1.1 Java Exceptions Summary
Exceptions Class Hierarchy in Java:
![Page 8: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/8.jpg)
1.1 Java Exceptions Summary
Exceptions C vs. Java/C++ approach:
![Page 9: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/9.jpg)
Fact: Java Exceptions In few samples it is simple to remember: Exceptions mechanisms and types in Java.
Section Conclusion
![Page 10: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/10.jpg)
Source Code Design Patterns
Source Code Design Patterns – factory methods, singletons
![Page 11: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/11.jpg)
1.2 Java Source Code Design Patterns Summary
Java Singleton:
http://searchdaily.net/category/java/designpattern/creational-pattern/
![Page 12: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/12.jpg)
1.2 Java Source Code Design Patterns Summary
Java Factory Method:
http://javamagic.wordpress.com/2010/08/27/factory-method-pattern/
Where to use & benefits Connect parallel class hierarchies. A class wants its subclasses to specify the object. A class cannot anticipate its subclasses, which must be created. A family of objects needs to be separated by using shared interface. The code needs to deal with interface, not implemented classes. Hide concrete classes from the client. Factory methods can be parameterized. The returned object may be either abstract or concrete object. Providing hooks for subclasses is more flexible than creating objects directly. Follow naming conventions to help other developers to recognize the code structure.
Bruce Eckel, “Thinking in Patterns with Java”, http://www.tutok.sk/fastgl/download/books/Thinking%20in%20Patterns%20with%20Java.pdf
One of the best book for source code design patterns.
“Singleton is used to control the amount of created objects.” In same category beside Singleton, there is Objects Pool.
Java Singleton:
![Page 13: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/13.jpg)
1.2 Java Source Code Design Patterns Summary
Java Factory Method:
http://javamagic.wordpress.com/2010/08/27/factory-method-pattern/
http://searchdaily.net/factory-method-pattern-tutorial/
![Page 14: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/14.jpg)
1.2 Java Source Code Design Patterns Summary
Java Factory Method:
http://searchdaily.net/factory-method-pattern-tutorial/
![Page 15: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/15.jpg)
1.2 Java Source Code Design Patterns Summary
Java Factory Method: http://searchdaily.net/factory-method-pattern-tutorial/
![Page 16: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/16.jpg)
Section Conclusions
Source code design patterns
for easy sharing
Source code design patterns such as:
Singleton, Objects Pool, Factory Methods…patterns used in any kind of software solution.
![Page 17: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/17.jpg)
Communicate & Exchange Ideas Share knowledge, Empowering Minds
![Page 18: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/18.jpg)
? Questions & Answers!
But wait… There’s More!
Recapitulation with samples… From previous lectures!
![Page 19: Lecture 5 summary of Java SE - · 1.1 Java Exceptions Summary Exceptions Types: 1. checked exception They are not passing by the compilation phase. May exist a “recovery” mechanism](https://reader035.fdocuments.us/reader035/viewer/2022081401/5f0465bc7e708231d40dc582/html5/thumbnails/19.jpg)
What’s Your Message? Thanks!
Java SE Programming End of Lecture 5 – summary of Java SE