Workshop 8 Review of Module MCT 619 (Workshop 8) This is the final presentation of the Object Oriented Programming module. In it, we will review some of the main points that were covered in each week of the module. Please note, however, that this review is not (and cannot be) comprehensive. For a thorough appreciation of what you are expected to have achieved in your studies of this module, you should refer to the overall module learning objectives and the individual workshop learning objectives as laid out in the Module Handbook. Naturally, you should also review the presentations from each week and study all of the sample programs again. Review of Module MCT 619 (Workshop 8) MCT 619: Object Oriented Programming MScSED
Workshop 1 Part 1: Overview of OOP Classes and objects are the defining features of OOP: More high-level than procedures/functions Greater intellectual manageability Improve software quality and design We have studied Java, a popular OOP language Developed by Sun in mid 1990s; popularised by Web Have discussed its principal characteristics The JVM provides platform independence Write once, run anywhere There are three Java Editions: Micro, Standard, Enterprise For development of different types of application. In the first lecture, we took a high-level look at the general features of OOP languages and Java in particular.
Workshop 1 Part 2: Beginning Java Programming We learned about: What the basic structure of a Java program is How to write elementary Java programs The fundamentals of using the Eclipse IDE What debugging is about The fundamentals of debugging in Eclipse In Workshop 1 Part 2, we considered the practicalities of writing, compiling and running simple Java programs.
Workshop 1 Part 3: Fundamentals of Java Syntax Details of Java’s syntax and how it relates to that of C: Fundamental data types Literal and Named constants Type conversion between numeric types and between Strings and numeric types Scope of variables Operators: arithmetic, relational, Boolean, assignment and some others In Workshop 1 Part 3, we examined the details of Java syntax, along the way noting the similarities and differences with C.
Workshop 2 Part 1: Control Structures We learned about: Decisions: if/else, switch Repetition: for, while, do-while, break, continue Methods must be defined within a class In Workshop 2 Part 1, we studied how to construct decisions, repetition and methods in Java.
Workshop 2 Part 2: Object-Based Programming We discussed: How OOP relates to how we think about the real world What classes, objects and references are How to display the design of classes and objects graphically using UML How to define classes in Java, create objects of those classes and work with references to them What the differences are between public and non- public classes How to define one or more constructors for a class, which are used to initialise objects’ properties In Workshop 2 Part 2, we began our study of object-oriented programming, starting with how to define classes and create objects of those classes.
Workshop 2 Part 2: Object-Based Programming continued.. Java has four visibility modifiers: public, protected, ‘friendly’, private It is a common programming convention to write getters and setters where the class design requires access/modification of properties Static member variables represent class-wide properties, and static member methods are needed to work with them We also examined a substantial example of object- based programming, defining a Time class We studied the fundamentals of defining classes and working with them.
Workshop 3 Part 1: Applets We learned: The distinction between applications and applets, as well as the main characteristics of applets How to develop simple graphical applets How to write HTML code to load an applet How to run an applet in a browser or appletviewer How to pass attribute values from a HTML file to an applet In Workshop 3 Part 1, we discussed the characteristics of Applets and how to develop them.
Workshop 3 Part 2: Graphical User Interfaces (GUI) We learned that: There are swing classes for all standard GUI components In an applet, components are typically created as private class members and then added to the content pane When the user interacts with a component, an Event object is created and an appropriate EventListener associated with the component can respond to it GUI builders greatly simplify the contsruction of event-driven applets and applications JavaBeans are reusable software components that can be visually composed into applications and other types of program In Workshop 3 Part 2, we learned about how to develop graphical user interfaces in Java and the basics of event-driven programming.
Workshop 4 Part 1: Classes as Building-Blocks I We learned that: Modularity is achieved in Java through the use of methods, classes and packages Encapsulation allows us to view objects in terms of their behaviours, not their internal structure We can derive subclasses from parent classes using inheritance, which is a powerful form of code re-use Subclasses can provide method definitions that override those in the parent class that have identical method signatures In the two parts of Workshop 4, we moved onto more high-level OOP topics. You learned about the concepts of modularity and encapsulation, and also how to re-use existing classes to construct new classes, using the mechanisms of inheritance and composition. Finally, we discussed the basic principles of object oriented design.
Workshop 4 Part 2: Classes as Building-Blocks II The Substitutability Principle is a good way of determining whether your design makes appropriate use of inheritance Java has a single-rooted class hierarchy, with Object at the root; Object defines specific methods that all classes inherit Composition involves defining a class with members that themselves are classes Inheritance implies an IS-A relationship between classes; composition implies a HAS-A relationship Java has automatic garbage collection Good object-oriented design requires domain knowledge, careful thought and experience Part 2 continued directly from Part 1.
Workshop 5 Part 1: Polymorphism and Worked Example We discussed how: Polymorphism permits related classes having consistent programming interfaces but producing different behaviours specific to themselves Polymorphism is enabled through dynamic binding of methods You may not create instances of an abstract class; it represents the commonality between derived concrete classes There are specific rules for casting references An interface specifies a list of pure abstract methods that any class implementing it must define; a class can implement multiple interfaces instanceOf, getClass and getName are for run-time type identification In Workshop 5 Part 1, you learned about Polymorphism, along with the related concepts of abstract classes and interfaces. We then moved on to studying a substantial worked example (the Payroll system) that demonstrates many of the concepts we have seen in this and the past two workshops.
Workshop 5 Part 2: Worked Example Cont'd; Exceptions In the Payroll example, you saw how to: Define a hierarchy of classes, some abstract Define constructors and override methods Use super to call parent's constructor and other methods Work polymorphically with objects in hierarchy In Exception Handling, you learned about: How exceptions can be used to handle recoverable errors How to catch or declare to respond to exceptions How to write try/catch/finally blocks What the difference is between checked and unchecked exceptions How to define your own Exception classes In Part 2, we concluded the Payroll example and then moved on to studying exception handling.
Workshop 6 Part 1: Arrays and Collections We learned that: An array is an ordered list of variables/ references, with fixed length, indexed from 0 Created using new keyword; square brackets [ ] to reference elements An array name is a reference like an object reference; its length is given by length property May be multi-dimensional and ragged; can use a sub-array reference to refer to section of full array Class java.util.Arrays has static methods for sorting, searching, comparing, etc. The Collections Framework is for managing many types of collection (including sets, lists and maps); it is comprised of Interfaces, Implementations and Algorithms The ArrayList class is the Collections class with features most similar to an ordinary array In this workshop, we learned about arrays. While the syntax is similar to that of C, many details of array creation and handling are different from C. As well as the standard array mechanism, the Java API includes an extensive Collections Framework, which provides much more sophisticated management and handling of collections such as arrays, lists and sets. The Collections Framework is a large topic; we looked only at an overview of it, and then we studied ArrayList, one of the popularly used collection classes in the Framework.
Workshop 6 Part 2: Files and Streams We discussed how: Java's procedures for file I/O are completely different from those of C There are several classes which may be daisy-chained for text I/O, and variations such as Formatter/Scanner Exception handling is important as many of the methods throw checked exceptions Object Serialisation is used for object storage and transfer Lightweight object persistence requires very little coding, but you can implement custom object serialisation if you wish The RandomAccessFile class has methods seek, skipBytes and getFilePointer The File class supports platform-independent file & folder operations In this lecture, we covered how to use Java's extensive input/output framework. As well as learning the basics of file reading and writing, you learned about how to serialise objects to and from files, how to work with random access files, and how to manage files and folders.
Workshop 7 Part 1: Multi-Threaded Programming I We learned that: Java achieves concurrency by supporting multiple threads of execution; threads are like 'lightweight processes‘ There are two ways to create a thread: implement Runnable or extend Thread The life-cycle of a thread involves five main states: new, runnable, waiting, timed waiting and terminated Multi-threaded programs may be used for many purposes, including responsive GUIs and applets with animation In this workshop (Parts 1 and 2), you learned how to develop programs with concurrency, which is the ability of a program to do more than one thing at a time and is an essential aspect of modern programming. As you found out, concurrency is achieved by having multiple threads of execution in our programs. We also discussed the distinction between processes and threads, what the life-cycle of a thread is, how to implement multi-threaded programs in Java, what synchronisation is, and what deadlocks are and how to avoid them.
Workshop 7 Part 2: Multi-Threaded Programming II Multiple threads often require synchronisation to ensure they do not try to read/change the same data in memory simultaneously Improper use of synchronisation can lead to deadlocks, as illustrated by the Dining Philosophers The producer/consumer problem demonstrates how bad synchronisation can result in deadlocks or race conditions Methods wait and notify are used to temporarily release locks so as to avoid deadlocks Workshop 7 Part 2 continued on directly from Part 1.
The End! This concludes this workshop and this module. Thank you for your attention and good luck with the final exam!