Skip to main content
  1. JavaFX/
  2. The Absolute Beginners Guide to Reactive JavaFX/

Part 11 - A "Working" Application

4 mins·
Table of Contents
Absolute Beginner's Guide - This article is part of a series.
Part : This Article

Reviewing What We’ve Done So Far
#

At this point we’ve actually got a simple, but fully functional “Create” application. It doesn’t have anything more than an account number and a name, but to get this far we had to put together a lot of moving parts.

This is probably a good time to pause, and look at what we’ve done.

We’ve Built on a Framework
#

If you’ve followed along this far, then the value of building on a framework should be readily apparent.

Here are some of the things it does for us:

We Can Use Unit Tests
Because we now have a pretty clear dividing line between the Reactive JavaFX code and the rest of our application, it’s now clear that some of our code is just plain old Java code and there’s nothing special about it. That means that we can test it, and in turn that means that we should test it.
Our GUI is Just the GUI
There’s no business logic in our GUI, it’s just layout.
Coupling is Minimized
Within the framework, there’s no dependency between the View and the Interactor. They both deal with the Model, but don’t even know of the existence of each other. Within our View, the various screen widgets have virtually no knowledge of one another.
Everything is Easy to Find
There’s no need to go looking for code. You won’t find business rules in the View or the Model, they’re all in the Interactor.
Everything is Small
No 1000 line classes here. Keeping everything broken up into discrete parts means that all of the parts stay small.

Other Important Ideas
#

Reactive Programming
Through this processes, we’ve seen how Reactive programming concepts make it easier to separate our components without having to worry about how they are going to be used. Having a synchronized data object holding our application state enables this.
Background Threads
We’ve learned about the importance of keeping blocking operations off the FXAT, and how to use Task to start up a process that runs on a background thread. We’ve also learned how to set up our GUI before a background task starts, and how to trigger the GUI to respond to the completion of a background task.
Single Responsibility Principle
We looked at how a method should only be directly responsible for a single thing and how, by delegating to other methods our code stays simple and easy to read.
Don’t Repeat Yourself (DRY)
We’ve seen that this is the most important principle for dealing with the boilerplate code that bog down a JavaFX layout. As we go on, we’ll see this become even more important.
GUI Validation
We’ve applied validation to our GUI to enforce business rules built by the Interactor and embedded into the Model.
Simulated Database and Access
We’ve seen how to simulate a database and connect it to our Interactor through a Broker and a DAO. We’ve dealt with the issues that latency can have when testing these components.
Handling Exceptions
We’ve learned about the difference between checked and unchecked exceptions and how to deal with checked exceptions that happen deep down a chain of method calls. We learned how to transform an exceptions into an action result, and integrate it into our UX.

Moving On From Here
#

Our next steps are going to build on what we’ve done so far:

Add Another Field
We’ll add a “Phone Number” field to the screen so that we can see how the feature build cuts all the way through the application from GUI to the database.
Clean Up the GUI
It’s going to become clear that our GUI is a bit ugly when we add another field. In the process of cleaning up the GUI, we’ll see how our layout has become cluttered with stuff that isn’t strictly…layout. We’ll clean that up and see how an even nicer looking GUI can actually take up much less code in our ViewBuilder.
Split the Name
We’ll divide the “name” field up into three parts including a “salutation” field that will let us use a ComboBox.
Add the Rest of the Fields
We’ll add a bunch of address fields to our screen, and then down through to our database.
Add a “Retrieve” Function
Finally, we’ll be ready to add the next CRUD function, “Retrieve”. Without “Retrieve” we can’t do “Update” or “Delete”
Absolute Beginner's Guide - This article is part of a series.
Part : This Article

Related

Part 10 - Handling Database Errors

9 mins
The last problem with our application is that it can save duplicate customer records, corrupting our database. This means adding some rules to our database and telling our GUI when those rules have been broken. We’ll see how to handle exceptions from the back-end in our application.

Part 12 - Adding a New Field: eMail

6 mins
It’s finally time to add a third field to our screen! In this article we’re going to add just a single new field, for email, to our screen. We’re going to see how the process goes from the View all the way down to the Broker. Most importantly, we going to see how we need to be vigilant in ensuring that our code stays clean as we add more features.

Part 13 - Feature Envy

8 mins
In this article we’re going to look at how Feature Envy has crept into our View code. We’re going to look at why this happens, and how to deal with it. Finally, we’re going to see how clearing out Feature Envy makes our code much cleaner and easier to understand.

Part 3 - User Interaction

11 mins
GUI applications need a way for the user to interact with them. In this lesson we’ll show how to allow user input with TextField, and to launch an action with a Button.

Part 4 - Styling

8 mins
JavaFX includes Cascading Style Sheets for styling the elements of your GUI. This is a quick guide about how to use them.

Part 5 - Application Framework

3 mins
Building an application that “does something” means adopting a framework that works well with JavaFX. Here we build the skeleton of the Model-View-Controller-Interactor framework that we’re going to use for our CRUD application.

Part 6A - First Feature: Minimal Create

10 mins
The first feature for our CRUD application has to be “Create”. In this lesson we’ll get started by designing the GUI and connecting it to the Controller.