Wiki

Clone wiki

oop / Home

Other pages: About the Course. Course Repository. Results and Feedback on assignments.
Results: PA1, PA1 Unit Test ArrayIteratorTest.java. PA2, LabExam 1, Quiz2 Feedback, Quiz3, Quiz4, Quiz5 and Feedback


Final Exam

Lab Exam: Thursday, 18 May 13:00-18:00, Room 201.
Project Presentations: Friday, 26 May 16:00-18:00, Room 204. Explain interesting technology you used so everyone can learn!
Written Exam Friday, 26 May 9:00-12:00, Room 204. Closed book.
Dress Code: "dress like a programmer" (wear anything you like).


Week 14

Review homework on concurrency.
Review bit operators: and, or, xor
Generic types, type parameters, and generic methods.
Introduction to Streams.
Common Design Patterns: Observer, Factory Method, State, Strategy, Adapter, Singleton
Design Patterns Practice in "patterns" folder.

Lab

  • Review Observer Pattern
  • Programming Quiz on Observers in GUI
  • Lab14 Generics and Streams. Apply Generics and Streams to some methods in CoinUtil.
  • Work on projects.

Assignment

  • Email me the URL for your project repo. One repo per team (you should both commit to same repo).
  • Create good online documentation for your projects.
  • Document at least the following:
    • What the project does.
    • Interesting code or technology you used, with a simple example and references so others can learn.
    • Names of authors. Use @username for Github references.
  • Consider using Github Pages (not required but looks much nicer); Wiki for project docs or so others can contribute!

Week 13

Review of Threads homework.
Threads in Swing (from last week) with demo. Slides in week12 folder.
New Features in Java 8:
Lambda Expressions, Interface new features, Immutable Date & Time classes.

Lab

  • Quiz on Recursion
  • Discuss JUnit tests for Withdraw Strategy - use a Purse attribute, setUp method, and utility methods to simplify tests.
  • Methods with variable length parameter list
  • Lab13 OCSF Framework. This is an introduction to frameworks. Files for this lab:
    • ocsf-231.zip contains ocsf-2.31.jar, source code, and Javadoc.
    • demoserver.jar question server you can use to test your client. Run it from command line using java -jar demoserver.jar.
    • Object-Client-Server-Framework.pdf chapter about frameworks and OCSF from the book Object-oriented Analysis & Design by Lethbridge. Chapter describes basics of creating a network connection in Java and how to use OCSF.

Assignment

PA5 Multi-threaded Downloader using threads for faster file downloads, as done in FlashGet and Filezilla. Optional this isn't required, but you can use this project is place of some other PA you missed, or as your PA6 project.
Read: Lambda Expressions in Java 8 tutorial (new feature in Java 8).
Read: Interfaces in Java 8 tutorial. Java 8 Interfaces my write-up (optional).
Homework: Homework 4 due next week in lecture. (from last week)


Week 12

Review Sequence Diagram from Last Week
Recursion and back-tracking
Coin Purse withdraw using recursion (and why)
Strategy Pattern
Threads
Threads in Swing
Intro to Lambda expressions

Lab

Assignment

Read: 1) BIGJ Chapter 20 (Threads).
Read: 2) Concurrency and Swing Concurrency in the Java Tutorial. You are responsible for this material, including synchronization.
PA6 Custom Project Design your own programming project and submit a proposal. Due: May 5 (Friday) Homework: Homework 4 due next week in lecture.


Week 11

Testing with JUnit.
Observer Pattern, Observers in Java, Observers in Swing components.
Using observers to notify UI of changes in app model.
Self-study: Assertions and "programming by contract". (see slides in week11 folder)

Lab

  • Quiz on Git: add file, remove file, move file, clone, push to remote
  • Two programs in the lab this week.
  • Lab11 StackTest write JUnit tests for a Stack. See lab sheet for stack specification.
    Download Stack.java (interface) and StackFactory.jar for testing.
  • Observable Coin Purse with GUI add a graphical user interface and observers to the coin purse.

Assignment

PA6 Custom Project Design your own programming project and submit a proposal. Due: one page proposal due in 2 weeks.


Week 10

No class this week due to holiday. Lab cancelled, too.
Please start work on PA4.

Assignment

PA4-Readability an app that measures the reading difficulty of text. This is a useful application. Due: April 30.
Test file: Alice in Wonderland with simplified punctuation.


Week 9

State machines - modeling components whose behavior depends on state.
UML State Machine Diagram
Programming a state machine
State Design Pattern (programming without "if")
Recursion

Lab

Assignment

Homework: Homework 3 in week9 folder. Due next Friday (7 April).
Read: UMLD Chapter 10 (State Machine). UML for Java Programmers Chapter 10, by Robert Martin, is also good and easy to read.
State Machine the web: UML State Machine; Wikipedia has pages about State Machine and UML State Machine.


Optional: Databases with JDBC and ORM

We didn't have time to cover this. Its not core to OOP and some students have already learned it on their own. Since databases are a common part of apps, you might want to know some of the basic concepts.

Fundamentals:

  • Some common databases, including client-server and embedded.
  • Uniform Resource Locators (URLs) used to identify resources such as databases
  • Simple SQL queries and commands.
  • The 4 basic operations: create, retreive, update, and delete (CRUD)

Java Howto:

  • Using JDBC to access a database
  • Object-Relational Mapping (ORM) to save and retrieve objects in a database. Many apps are simpler if let an ORM framework do the work for you, instead of using JDBC yourself. EBean and ORMLite are easy to use.
  • For Java, the Java Persistence API (JPA) is the standard. EclipseLink is the reference JPA implementation. We won't cover JPA, but EBean uses much of the JPA API.

First Half of the Course

Week 1

  1. Preliminaries.
  2. Review of Java basics
    • Ex - Java exercise
    • Ex - Java naming convention. Identify types of names.
  3. Java coding standard and Javadoc.
    • How to use the Java API docs (Javadoc).
    • Ex - fix the code (in lab)
  4. Introduction to object and classes. A conceptual interpretation of objects.
    • Three characteristics of objects.
    • Example and exercise
    • Why program with objects?
    • The problems of software design and development.
    • O-O fundamentals and the "3 pillars" of O-O paradigm.
    • Polymorphism: Why can we "print" any object? How does Java handle this?
    • Encapsulation and access control: public, protected, private.
    • Inheritance.
    • Ex - use encapsulation to change implementation of Matrix or Classroom (OOP1).
  5. Object References.
    • A reference is not an object.
    • A useful analogy: reference is like a "remote control" for an object. The buttons are the object's methods. This helps explain how polymorphism works.

Assignment 1. Do this before lab tomorrow.

  1. Install the command line git on your computer, from https://git-scm.com/download/. (Windows, MacOS X, or Linux)
  2. After you install git, you should set your name and email. Execute these commands (with your name and email):
    cmd> git config --global user.name "Fatalai Jon"
    cmd> git config --global user.email fatalai.j@ku.th
    
  3. Create an account on Github.
  4. Edit your Github profile and include:
    • your real name, in English with correct capitalization.
    • a photo that clearly shows your face.
  5. (Helpful) Read a Git tutorial of your own choice. Try Git lets you try git in your browser and contains more than you need to know.
  6. Git Cheat Sheet (PDF) has summary of useful commands.

Lab 1

There are 2 parts to the lab. The files are in the week1 folder.

  1. Lab1-1-Git.md practice using git.
  2. Lab1-3-Guessing-Game write a Guessing Game in Java. See the PDF for instructions.
    • In Lab: commit source code for a game that works, and README.md file.
    • "push" a copy of your repo to your Gtihub account as GuessingGame repo
  3. Due Tomorrow (Saturday):
    • write good Javadoc for classes and methods. Use @param, @return, @author tags.
    • fix any problems with your code.
    • format code to be easy to read.
  4. Tell us your Github account. Complete this form: https://goo.gl/Y6EMeq.

Assignment

Read: (1) Java Coding Standard, (2) Java Fundamental Methods
Learn: UML class diagram for a single class. Use the Internet or read UMLD Chapter 3 (Class Diagram).
Homework: Homework 1 due next week


Week 2

Topics left from week1:

  • How Java and the JVM work.
  • Object references.
  • Coding standard and Javadoc.
  • How to read the Java API (you should already know).
  • Fundamentals: correct way to write equals.

This week's topics:

  1. Introduction to Polymorphism.
    • A key to the power of the O-O paradigm.
    • There are two ways to use polymorphism in Java: inheritance and interfaces.
    • Both ways are useful, but interfaces are more flexible.
  2. Interfaces in Java. One of key ways to enable polymorphism.
  3. Designing with Interfaces. Factoring out common behavior.
  4. UML Class Diagram.
    • How to show attributes, methods, visibility, static, and constants.
    • How to show interfaces and "implements".
    • How to show relationships: dependency, association, inheritance.

Lab 2 DUE TO HOLIDAY, LAB ATTENDANCE IS OPTIONAL. YOU CAN DO THIS LAB AT HOME.

The Lab will be open (13:00-16:00) and you can get help/feedback from TAs. Alternatively, you can do this lab at home and submit to Github.

  • Lab2: Stopwatch in Week 2 folder.
  • Submit your Stopwatch and refactored tasks to Github as a project named stopwatch.
  • Deadline: 2 Feb 2017 (Thursday), midnight
  • Code Review: TAs will review week1 lab for some students

Exercises

  1. Name 2 classes in Java API that you cannot create an instance. How do you know its impossible (e.g. no Factory method)?
  2. Name 2 classes in Java API that you cannot use "new XXX()" but you can create objects using a static method in that class.
  3. Name a class in Java API that you cannot use "new XXX()" but you can create objects using another class (either static or instance method).

Assignment

Read: Let's Eliminate Duplicate Code (http://goo.gl/TGiUqC) by Thai, explains how to use interface to remove duplicate code. Improves your code.
Read: Polymorphism and Interfaces in BIGJ 9.6 and 10.1-10.6.
Programming Assignment: PA1-ArrayIterator available now. Due: 5 Feb 2017 (Sunday), midnight.
Quiz After KU Fair: Quiz on UML Class diagram, writing the Fundamental Methods, and Polymorphism


Week 3

Collections, Lists, and ArrayList
Interfaces used to Sort Arrays and Lists
Why Iterators?
Java for-each loop for arrays and collections
Using the Java API Docs
UML class diagram, details. (By now you should have read the basics of class diagram on your own.)
Quiz high probability of a quiz on Java fundamental methods, UML class diagram, and polymorphism.

Lab

  • Resolving conflicts in git. This happens when you edit a file on Github via web browser, then try to push code from your local repo. Solution is to pull changes from Github before commiting your own changes.
  • Practice using List and ArrayList
  • Practice writing a Comparable and Comparator.
  • Lab3-Coin Purse using List. There is sample code (purse-sample.zip) to get started, in week3 folder.

Assignment

Read: 1) BIGJ chapter 15 on Collections. 2) "for-each" loop is covered in BIGJ section 7.2. 3) Review week2 reading on Interfaces.


Week 4

Inheritance - why use it?
Abstract Classes for common code in a class hierarchy.
More Collections: Map and Abstract collection classes.
Design using Interface and Abstract Superclass
Using the Java API Docs

Lab

Assignment

Read: Inheritance and Abstract classes in BIGJ chapter 9. Abstract classes also in OODP section 6.3.
Study (know how to apply) my Inheritance-1-Basics slides. Tell me next week if it contains anything you did not learn in OOP1.
Homework tba
Quiz next week on interface, inheritance, collections.


Week 5

Design using Interface and Abstract Superclass (from last week)
Java "final" modifier
Principles (guides) for Better Code
Creating objects using Factory Methods and Singleton (instead of "new ...")
Quiz on collections, Java collections hierarchy, interface, and inheritance.

Lab

  • Lab5-1 Coin purse with abstract class for money
  • Lab5-2 Coin Purse with Money Factory and Singleton

Assignment

Read: BIGJ Chapter 9 (Inheritance) covers abstract class and "final". Factory methods are covered in OODP section 10.3, or search the web.
Homework: Homework 2 Problems 1-4 due in class on Thursday, 2 March. Problem 5 due in Github, Friday, 3 March. Any copying results in grade "F" for the course.


Week 6

Exceptions and Exception Handling
The Java IO Hierarchy
Inner classes
Anonymous classes
Writing DRY Javadoc using @see tags. You can also use HTML in Javadoc
Design Issues in Coin Purse

Lab

  • I/O and Exceptions lab
  • Clean up and review previous labs

Assignment

Read: BIGJ Chapter 11 on Input/Output and Exception Handling. Exceptions also covered in the Java Tutorial (JTUT).
Programming Assignment: PA2-CSVReader assignment in week6 folder. Due: Monday, 13 March, midnight. * Please use the Github Classroom link (sent to you via email) to create a repository for this assignment. You don't need to request your own private repos. * After you visit the link and "accept" the assignment, clone the repo to your computer and put your work in there.


Week 7

Graphical User Interfaces (GUI) in Swing
Swing Components
Event listeners and the Observer Pattern
How to write a simple GUI

Lab

Assignment

Read: BIGJ Chapter 19 on Graphical UI; OODP Chapter 4 on design patterns in Swing (recommended).
Programming Assignment PA3-UnitConverter due 3 April. Use the Github Classroom repository (invitation sent by email) and use git to commit -- don't use file upload. Assignment URL is: https://goo.gl/XCp7NJ


Week 8

Enum type
Actions - commands that encapsulate EventListeners
Model-View in Swing components
UML Sequence Diagram (if we have time)
Review
Practice Problems

Lab

PracticeExam, the project code is available as a Github classroom project. Check your email for invitation.
The invitation link is: https://classroom.github.com/assignment-invitations/d7061f4cba270d7925e0a714d4e081b4

Assignment

Read: UMLD Chapter 4 on Sequence Diagram, Chapter 5 on Class Diagram "advanced" concepts.


Midterm

Written exam 24 Mar, 12:00-15:00 in room 204. Closed book.
Any material from lectures and reading assignments may be included on exam. Reading material may be included even if never discussed in class.
Programming exam 24 Mar 16:00-19:00 in room 201. No internet, notes, slides, or code allowed. Only an IDE, JDK, and Java API docs.
Dress code: dress like a programmer (wear anything comfortable).


References

[BIGJ] Cay Horstmann, Big Java, 4E or 5E.
[JTUT] Oracle, Java Tutorial.
[UMLD] Martin Fowler, UML Distilled, 3E.
[OODP] Cay Horstmann, Object-oriented Design and Patterns, 2E.

Updated