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

Moving On - Building A CRUD Application

3 mins·
Table of Contents

Introduction
#

So far we’ve built an application that does little, but demonstrates a lot. Now we’re going to write one of the most common types of application out there - CRUD (Create, Retrieve, Update and Delete).

Our example is going to be something super common, some sort of a customer database where we can add new customers, look them up in a number of ways, and then modify or delete them.

Software Architecture
#

Most software applications have a structure that looks something like this:

App Structure

The top three horizontal boxes (in green hues) represent the GUI elements of the application. Individual Labels, TextFields, ComboBoxes and such are at the top, then actual layouts that contain them. The bottom layer of the GUI is the part that contains the mechanics. These are the things that control actions from the GUI, instantiate the GUI and, of course, the State.

The blue layer is the business logic layer. This is the part that contains the logic which is specific to whatever function the GUI supports.

Under that, in pink colours are the “external” elements that connect your application to other applications, the persistence layer and calls to external API’s. The “Brokers” layer is responsible for fetching data from these other services and packaging the results into “domain objects”, which can then be dealt with by the Business Logic layer.

Features and Scope
#

The most important thing, is that when you develop an application you implement one feature at a time, and feature always cuts a vertical slice through the application structure - from screen widget right through to external API call. When you expand the scope of a feature, you are cutting a wider slice through the entire application structure.

What this means is that you can’t just add a TextField to a screen and not create the rest of the structure to handle the data in that TextField right down to your database. On on the other end, if you’re also creating the database, you can’t add fields to it without creating the Brokers and DAO’s and business logic to pass it to the GUI and put it on the screen.

You build your application by starting with a single feature, no matter how small, and implement it from top to bottom in the application structure. And all the way, you stick to YAGNI (You Ain’t Gonna Need It) as your guiding principle. This means that you ONLY build things directly required to implement the feature that you’re implementing. No peeking ahead.

As you continue to build your application, you can expand the scope of a feature, or add new features (very often this is just a matter of semantics). All the while, making sure that you build out each feature from top to bottom of the application structure, and only building the things you need.

This is the process we’re going to follow to create our Customer Database application.

Testing
#

The unfortunate truth is that GUI’s are problematic to test. There are automated tools, but they are complicated and difficult to set up. The best thing to do is test by hand.

However, the rest of your system can, and should, be tested, and if your architecture allows for a clean separation between the GUI and everything else (and ours will), you can do unit testing easily.

Related

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 6B - Adding Persistence

14 mins
In this lesson we finish up a “bare-bones” Create function by building the back-end and connecting it to the business logic in the Interactor. Part of this involves creating a simulated database.

You Need a Public Domain

21 mins
If you are self-hosting, then you should probably have a public domain registered. In this article, we’ll look at why you should do this, and the things that it helps.

Managing DNS Services

22 mins
Everything you need to know about DNS if you are self-hosting. How to use Technitium to host a private DNS server in your homelab.

Whole Home Audio With SnapCast - Part III

14 mins
The final installment of a 3 part series describing how to set up whole-home audio using SnapCast, Mopidy and Rasberry Pi’s. In this article, we look at how to install and configure Mopidy as a streaming service, and how to connect it to a SnapCast server.

Whole Home Audio With SnapCast - Part II

14 mins
Part 2 of a 3 part series describing how to set up whole-home audio using SnapCast, Mopidy and Rasberry Pi’s. In this article, we look at how to configure a Raspberry Pi Zero as a SnapCast client.