CS 342 - 12/7/17 Final Exam - Friday 12/15/17, 1pm - 3pm LC-D4 (for those in 11am section) LC-E1 (for those in 12:30 section) You are allowed 2 sides of 8.5x11 inch paper with whatever notes you wish. - no special reading devices other than regular eye-glasses The BigInteger method of modpow () can help code run faster. For Final Exam: Prof Wei reviewed some info on 11/21/17 Includes many ideas for Design patterns and related principles for OOP Topics Covered: Threads Thread class (via inheritance - "is-a") Runnable Interface (via composition - "has-a") start() method run() method Shared Data Race Condidion / Data Hazard - updates occurring that cause the data to get into an invalid state Java synchronize keyword can help reduce data hazard Often set up via a data member of the Class "containing" the thread/runnable where the instance in created before the thread is started and its reference is passed into the constructor of the class. A second way is to use a static data member. A third way is to use the Singleton Design Pattern. The second and third way do restrict the program so that the is a single set of shared data between all of the threads. We can't use these to create multiple groups of threads where group contains different instances of the shared data. Sockets - can be asynchronous - ideas of an Event Driven Program resurface here - however, no event loop (in Java exist) as occurred when programming GUI Event Driven Programming ServerSocket class - used to establish the connection - constructor() - used on the server side to establish the listening port - accept() - establishes connection - returns the Socket class instance that is connected to the client Socket class - used for communication - constructor() - used on the Client side to connect to a listening ServerSocket Once connected - access the input stream and output stream for communication Depending on the type of data being sent across the socket, wrap the inout and output streams in the appropriate I/O classes. Design Patterns - UML-ish Diagrams Top Design Patterns - Observer - Adapter - Singleton - Factory - Strategy - Iterator - Decorator - Facade