--- tags: computer science, java --- <center> # **Advanced Java Programming** :::info Location: Room nnn, 德田館 Time: 1300 ~ 1600 ::: </center> <div style="text-align: right">``xxx''<br>-- xxx</div> <br> ## **Class Information** ### Instructor - Name: 盧政良 (Zheng-Liang Lu, Arthur) - Email: arthurzllu@gmail.com ### Objectives - Advanced topics around Java: generics, lambda, stream, reflection - Dependency management: Maven & Gradle - Design patterns: TBD - Memory management and performance profiling - MySQL + JDBC + ORM - Logging - Unit test ### Prerequisites - [Java Programming](https://www.csie.ntu.edu.tw/~d00922011/java.html) - You should have basic knowledge about Java, especially the OOP chapter!!! ### Working Environment - JDK17+ on Eclipse ### Recording Classroom Lectures Policy :::warning Recording of classroom lectures is <font color="red">**prohibited**</font> unless advance written permission is obtained from the class instructor and any guest presenter(s). ::: ## **Overview** ### Design Patterns - Creational patterns: singleton, factory method, abstract factory - Structural patterns: adapter, bridge, proxy, decorator, sharing (interning, flyweight) - Behavioral patterns: iterator, strategy, observer (publish/subscribe) - Model-control-view (MVC) model ### Advanced Java - Generics - Collections: List (ArrayList & LinkedList), Map (TreeMap & HashMap), Set (TreeSet & HashSet) - Anonymous function (lambda) - Stream API: upgraded collections with functional programming - Optional API: alternative to null (a billion-dollar mistake) - Reflection and annotation ## **Schedule** ### ++Warm Up++ - A quick review on OOP: [pdf](https://www.csie.ntu.edu.tw/~d00922011/java2/java2_oop.pdf) [stanford](https://web.stanford.edu/class/archive/cs/cs106a/cs106a.1152/lectures/Memory.pdf) - Java 面試 - JVM 的 Stack 和 Heap [link](https://blog.marklee.tw/java-interview-jvm-stack-heap/) - (FYR) Josh Ko, [物件導向編程精要](https://www.csie.ntu.edu.tw/~htlin/course/oop13spring/doc/EssentialOOP), 2007 ### ++Selected Design Patterns++ - Delegation and strategy pattern: [pdf](https://www.cs.colorado.edu/~kena/classes/5448/f12/lectures/07-designpatterns.pdf) [code](https://home.cs.colorado.edu/~kena/classes/5448/f12/code/lecture07examples.zip) - Bridge pattern, adapter pattern, proxy pattern, decorator pattern, factory method, and abstract factory pattern: [pdf](https://www.cs.colorado.edu/~kena/classes/5448/f12/lectures/10-strategybridgefactory.pdf) [code](https://home.cs.colorado.edu/~kena/classes/5448/f12/code/lecture10examples.zip) - Observer pattern, template method, state pattern, flyweight pattern: [pdf](https://home.cs.colorado.edu/~kena/classes/5448/f12/lectures/25-moredesignpatterns.pdf) [code](https://home.cs.colorado.edu/~kena/classes/5448/f12/code/lecture25examples.zip) - Model-View-Control (MVC) model [pdf](https://home.cs.colorado.edu/~kena/classes/5448/f12/lectures/27-patternsofpatterns.pdf) [code](https://home.cs.colorado.edu/~kena/classes/5448/f12/code/lecture27examples.zip) - (FYR) 深入淺出設計模式精簡版 [link](https://github.com/kib06277/Head-First-Design-Patterns) ### ++Advanced Java++ - Generics [pdf](https://courses.cs.washington.edu/courses/cse331/19au/lectures/lec13-generics.pdf) - More articles about generics: [link1](https://www.oracle.com/technical-resources/articles/java/juneau-generics.html) [link2](https://www.journaldev.com/1663/java-generics-example-method-class-interface) - (FYR) How to use wildcards [link](https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html) - Case study: comparable objects [code](https://www.csie.ntu.edu.tw/~d00922011/java2/ComparableDemo.zip) - Lambda expressions and Stream API [pdf](https://www.cs.cmu.edu/~charlie/courses/15-214/2014-fall/slides/26-java8.pdf) [code](https://www.csie.ntu.edu.tw/~d00922011/java2/StreamDemo.zip) - Marius Herring, [Java 8: No more loops](http://www.deadcoderising.com/Java-8-no-more-loops/), 2015.1.25 - Optional API: [link](http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html) - (FYR) More about lambdas - Ted Neward, [Java 8: lambdas part 1](https://www.oracle.com/technical-resources/articles/java/architect-lambdas-part1.html) and [Java 8: lambdas part 2](https://www.oracle.com/technetwork/articles/java/architect-lambdas-part2-2081439.html), Oracle, 2013 - Richard Warburton, Raoul Urma, and Mario Fusco, [Java 8 Lambdas - A Peek Under the Hood](https://www.infoq.com/articles/Java-8-Lambdas-A-Peek-Under-the-Hood/), 2014 - Case study - [ParallelStreamWordCount.java](https://www.csie.ntu.edu.tw/~d00922011/java2/ParallelStreamWordCount.java) with a text file [The King James Bible](http://www.gutenberg.org/cache/epub/10/pg10.txt) - (FYR) 林信良, [神秘的Monad不神秘](https://www.ithome.com.tw/voice/86448), 2014.4.11 - Reflection & annotation [pdf](https://userpages.uni-koblenz.de/~laemmel/pttcourse/slides/meta.pdf) [code](https://www.csie.ntu.edu.tw/~d00922011/java2/ReflectionDemo2.zip) - (FYR) Glen McCluskey, [Using Java Reflection](https://www.oracle.com/technical-resources/articles/java/javareflection.html), 1998 - (FYR) Jakob Jenkov, [Java Reflection - Arrays](http://tutorials.jenkov.com/java-reflection/arrays.html), 2014 - Case study - Unit test [code](https://www.csie.ntu.edu.tw/~d00922011/java2/TinyJUnitDemo.zip) - Dynamic proxy [link](http://tutorials.jenkov.com/java-reflection/dynamic-proxies.html) [從監視攝影機理解 Log4j 跟 Log4Shell 漏洞](https://www.informationsecurity.com.tw/article/article_detail.aspx?aid=9631) ## **References** ### ++Java++ - Raoul-Gabriel Urma, Mario Fusco, Alan Mycroft, <a href="https://www.manning.com/books/modern-java-in-action">Modern Java in Action</a>, 2018 ![](https://i.imgur.com/T5MAJMF.png =100x) - Patrick Niemeyer and Daniel Leuck, <a href = "https://www.oreilly.com/library/view/learning-java-5th/9781492056263/">Learning Java</a>, 5/e, 2020 ![](https://i.imgur.com/1vomEDv.png =100x) - Benjamin J Evans and David Flanagan, <a href="http://shop.oreilly.com/product/0636920030775.do">Java in a Nutshell</a>, 6/e, 2014 ![](https://i.imgur.com/gvdEjcw.png =100x) - Joshua Bloch, <a href="https://www.amazon.com/Effective-Java-Joshua-Bloch/dp/0134685997">Effective Java</a>, 3/e, 2018 ([note](https://github.com/ekis/effective-java-3rd-edition)) ![](https://i.imgur.com/w2Cd3eo.png =100x) - Scott Oaks, <a href="http://shop.oreilly.com/product/0636920028499.do">Java Performance: The Definitive Guide</a>, 2014 ![](https://i.imgur.com/wl2K3Hg.png =100x) ### ++Design Patterns++ - Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Grady Booch, [Design Patterns: Elements of Reusable Object-Oriented Software](https://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented-ebook/dp/B000SEIBB8), 1994 ![](https://i.imgur.com/i5MbOYr.png =100x) - Eric Freeman and Elisabeth Robson, [Head First Design Patterns: Building Extensible and Maintainable Object-Oriented Software](https://www.amazon.com/Head-First-Design-Patterns-Object-Oriented/dp/149207800X/), 2/e, 2020 ([code](https://resources.oreilly.com/examples/9780596007126)) ![](https://i.imgur.com/Bzp4VGs.png =120x) - Robert C. Martin, [Agile Software Development, Principles, Patterns, and Practices](https://www.amazon.com/Software-Development-Principles-Patterns-Practices/dp/0135974445), 2005 ![](https://i.imgur.com/d89wcG2.png =100x) - Alexander Shvets, Gerhard Frey, and Marina Pavlova, [Dive Into Design Patterns](https://sourcemaking.com/design-patterns-ebook), 2018 ![](https://i.imgur.com/zpAUht2.png =100x) - 蔡昇達, [設計模式與遊戲開發的完美結合](https://www.books.com.tw/products/0010703628), 2016 ([github](https://github.com/sttsai/PBaseDefense_Unity3D)) ![](https://i.imgur.com/f34cvmr.png =140x) - Kenneth M. Anderson, [Object-Oriented Analysis & Design](https://www.cs.colorado.edu/~kena/classes/5448/f12/), Department of Computer Science, University of Colorado, 2012fa - Zach Tatlock, [CSE 331: Software Design and Implementation](https://courses.cs.washington.edu/courses/cse331/17wi/), Computer Science & Engineering, University of Washington, 2017 winter - Max Goldman and Armando Solar-Lezama, [6.005: Software Construction](http://web.mit.edu/6.005/www/fa16/), EECS, Massachusetts Institute of Technology, 2016fa - Josh Bloch and Charlie Garrod, [Principles of Software Construction: Objects, Design, and Concurrency](http://www.cs.cmu.edu/~charlie/courses/15-214/2016-fall/), Carnegie Mellon School of Computer Science, 2016fa - Stephen Wong, [Comp310: Advanced Object-Oriented Programming and Design](https://www.clear.rice.edu/comp310/s19/), Rice University, 2019sp - Andrew Myers, [CS 2112: Object-Oriented Design and Data Structures - Honors](http://www.cs.cornell.edu/courses/cs2112/), Department of Computer Science, Cornell University, 2020