This website provides the up to date information on course material, exercises and announcements about Programming in Java part 2, Class Design.

The module description can be found here.

Study the theory/ tutorials before you come to class. This will make the lessons most effective, because the questions that you might have from studying could be answered immediately.

Studying is not glancing over some (web) pages, but experiment with the compiler, IDE and other tools, to see if you can use the presented ideas and apply it in your own code.

Question answer section, filled by students and moderated by teachers and student assistants.
The Q&A section will stay rather empty, unless you contribute. It would be great if you added an answer to your question. It is a great way to test your teachers and your hypothesis. In any case we will moderate and add or improve answers before, in or after class.

To contribute, checkout qanda as e.g. java2sen1qanda in a place convenient to you, add your questions in adoc files in the qanda sub folder or any of its siblings, and add, and commit. We are using version control almost everywhere, remember. That also implies that we know exactly who’s account has been used to commit, in case you intended any pranks.

The solutions to the exercises will published in the same Shared Practicum Repository as the qanda section after lesson or the hand in deadline.

1. Part 1, 1st 7 weeks

1.1. Inheritance and polymorphism, Exceptions.

Week 1. Repetition from Java 1 and dotting the i’s.

Sheets and handouts
  1. Inheritance and polymorphism: sheets and handouts

  2. Exceptions: sheets and handouts .

Practical task for week 1

Beer exercise . Put the code it in week01, named beerexceptions.

1.2. Enums and Generics

Constants with functionality and more type safe storage.

Sheets and handhout
  1. Generics and enums sheets and handout

Practical task for week 2

A bad galactic dream . Put the code and documentation (adoc) in week02, you can start with the netbeans project

1.3. Lambda Expressions

1.3.1. The new stuff in Java 8.

For this week study Oracle Lambda Tutorial and the Stream Api Package Doc.

Sheets and handhout
  1. Lambda Expressions framework sheets and handout

Practical task for week 3

Dreaming on lambda. Put the code and documentation (adoc) in week03. You can continue with your netbeans project by making a subversion copy (using the url to url server side copy) of that work, but you might also want to have alook at the reference solution in reference solution olifantys generics.

1.3.2. Searching and the Application Of Lambda Expressions

  1. Collection framework sheets and handout

Oracle tutorial on aggregate operations with collections and streams.

Practical task for week 5

This weeks task is the same as for SEN1, the lambda library task description and netbeans project.

1.4. Serialization and File IO

Interaction with the file system, writing object to streams and files.

Sheets and handhout
Practical task for week 6

CSV to Objects and the students in students.csv .

1.5. Threads and sockets

Program a simple client server file transfer.

For this week study Oracle Networking Tutorial, in particular the part "All About sockets".

Sheets and handhout

Sheets on sockets and threads sheets and handout

Practical task for week 9
Implement a simple text translation server and client. The task description is in Simple rest api

1.6. Java Database Connectivity (JDBC)

How to work with a database directly from Java in a command line, desktop or web application.

Study the JDBC Introduction.

Sheets and handhout

The task for this week is an extension to the rest api of last week. The task description is this.

The startup project, which just defines the jdbc dependency is

1.7. Bindings (Java Beans, FX Properties)

Java Beans and JavaFX bindings.

Material to study this week Oracle javabeans tutorial, in particular the part "Writing JavaBeans Components"and thparticular the part "Writing JavaBeans Components" and the Oracle JavaFX Bindings Tutorial.

Short intro on the classic Java Beans and then the modern stuff, JavaFX Bindings.

Sheets and handhout

This weeks sheets sheets and handout

Practical task for week 12
Implement a DoubleBit GUI in JavaFx using JavaFx bindings The task description is in Java FX Double Bits GUI task description

You can download an up to date version of scenebuilder from the gluonhq webiste.

Mid Term tests

Mid Term exam and performance assessment After 7 weeks of lab and lectures, you will show your knowledge and skill in a theory exam and a performance assessment.
  • The exam is a written, paper based multiple choice exam.

  • The performance assessment is a combined assessment with SEN1.

    Topics  to study for the mid term exams:
  • For the Java2 theory exam:The subjects on this page, in particular the slides and the references public tutorials.

  • For the JAVA2 and SEN1 performance assessment the weekly exercises and exercises from Liang (the book) chapters 1 through 16 (same as Java 1). Choose those exercises for which you know you need more experience. Additionally you may want to read chapter 17 is about IO, which is also the topic of week 4, serialization and file and file io. Note that that theory is completely covered in the tutorials , but you might like an additional approach.

  • The JAVA-SEN1 performance assessment is taken in one session. The best approach is to develop test driven in small steps. Read the requirements of one method and write a test for it. You will have a better understanding of that requirement. Then write the implementation. The test will help assert if you did well. Do not linger too long on one question, but go to the next when you are stuck and revisit the task in a next round.

Code Style

Code style will help you read code and help us understand intent. Example: the way you name things. Types, with exception of primitives, start with a capital. Members, i.e. methods and fields start with a lower case letter. Exceptions: constants, such as static final fields and enum values are written all caps.

checkstyle logo 260x99

To help you improve your code style, you should use checkstyle , for which there is a NetBeans plugin. See the NetBeans IDE plugin portal for the Check style plugin . You can find a useful, and not too strict set of rules as sebivenlo_checks.xml . Download it to your computer, maybe in your ~/Library directory where you save your library jar files too. Then point the NetBeans checkstyle configuration to it, so that it can find your configuration. There also is an accompanying suppression file, called sebivenlo_suppressions.xml that helps suppress the most obnoxious checks, for instance those in test classes. Test classes require less stringent checks, which is true if you choose proper method names etc. The tests are mainly about the production code.

In the very near future (from 2017-02-18) we will configure the java related repository with a pre-commit check. That will use the same sebivenlo_checks.xml rule set and the mentioned suppression file .

2. Part 2, weeks 8-14.

2.1. RESTful Java with JAX-RS

Makes development of RESTful web services in Java simple.

Sheets and handhout

Sheets on numbers and threads sheets and handout

Practical task for week 8
For the exercises, see the slides.
Demo source code
For the demo source code SimpleRESTful and EmployeeClient, update your java2sen1 student repository.

2.2. Next steps in JavaFX

In semester one you worked on a JavaFX clock, in which you also used bindings. Hope you remember. You might want to revisit the solution in the Repository or indeed your own solution.

Now we take it a level higher and combine it with all you learned in this semester in MOD1, SEN1 and Java2 about state machines, enum etc.

Short intro on the classic Java Beans and then the modern stuff, JavaFX Bindings.

Sheets and handhout

This weeks sheets sheets and handout

To get up and running with the JavaFX client technology, visit the Oracle Java SE Client Technolgies and follow the JavaFX trails. Or visit, this tutorial discusses java fx table views with scenebuilder.

Demo source code
For the adapted SimpleRESTful and JavaFXSimpleTblView demo source code, update your java2sen1 demos student repository.
Practical task for this week.
We call the first scene builder view in Part 1 of javafx-8-tutorial a master detail view. Implement a master detail view for the exercise you started in week 8. The detail view must implement delete, edit and new. Study at least part 1 - 3 of the tutorial.

Optional task Java fx workshop by Kristjan Skutta and Marc Kempin.

2.3. Numbers and computation

On the proper handling and choosing of Numbers in Java. exercise description: see the sheets

Sheets and handhout

Sheets on numbers and threads sheets and handout

Number conversion table (appendix in exam).

Practical task for week 10
This weeks exercises are preparations for the written exam. For the exercises, see the slides.

2.4. Collection Framework & Comparator Interface

Organizing objects in collections.

Sheets and handhout
  1. Collection framework sheets and handout

  2. [Y.D. Lang] book paragraph 20.1 - 20.6

Practical task for this week
Download SimpleCollection example code, in the slides you’ll find what you have to do.

For this week study Oracle Java Collections Tutorial and book [Y.D. Lang] paragraph 20.1 - 20.6

Solution this week task, download Solution

You can download an up to date version of scenebuilder from the gluonhq webiste.

2.5. rehearsal.