Why I prefer trunk-based development

Photo of a tree at the side of the river in Sevilla, Spain

These days, distributed version control systems like Git have "won the war" of version control. One of the arguments I used to hear when DVCSs were gaining traction was around how easy it is to branch and merge with a VCS like Git. However, I'm a big fan of Trunk-Based Development (TBD), and I want to tell you why.

With trunk-based development, all developers work on a single branch (e.g. 'main'). You might have read or heard Martin Fowler or Dave Farley talking about it. It was when I was working with Dave (around about the time that Git was rapidly becoming the "go-to" version control system) that I really saw the benefits of trunk-based development for the team, particularly in an environment that was pioneering Continuous Delivery - Dave was writing the book with Jez Humble while I worked with him.

In contrast, the branching model encourages developers to create separate branches for every feature, bug fix, or enhancement. Although branching may seem like a logical approach to isolate changes and reduce risk, several factors make me more comfortable with trunk-based development.

Continue reading "Why I prefer trunk-based development"

What should every Java programmer know?

Front cover for the book "97 Things Every Java Programmer Should Know"

Preface to 97 Things Every Java Programmer Should Know

The mind is not a vessel that needs filling, but wood that needs igniting.

Plutarch

What should every Java programmer know? It depends. It depends on who you ask, why you ask, and when you ask. There are at least as many suggestions as there are points of view. In a language, platform, ecosystem, and community that affects the software and lives of so many people, and has done so from one century to the next, from one core to many, from megabytes to gigabytes, it depends on more than one could ever hope to cover in a single book by a single author.

Instead, in this book, we draw on some of those many perspectives to collect together for you a cross-section and representation of the thinking in the Java-verse. It's not every thing, but it is 97 of them from 73 contributors. To quote the preface of 97 Things Every Programmer Should Know:

With so much to know, so much to do, and so many ways of doing so, no single person or single source can lay claim to “the one true way.”. The contributions do not dovetail like modular parts, and there is no intent that they should—if anything, the opposite is true. The value of each contribution comes from its distinctiveness. The value of the collection lies in how the contributions complement, confirm, and even contradict one another. There is no overarching narrative: it is for you to respond to, reflect on, and connect together what you read, weighing it against your own context, knowledge, and experience.

What should every Java programmer know? In the 97 things we have sampled, the answers span the language, the JVM, testing techniques, the JDK, community, history, agile thinking, implementation know-how, professionalism, style, substance, programming paradigms, programmers as people, software architecture, skills beyond code, tooling, GC mechanics, non-Java JVM languages… and more.

In the spirit of the first 97 Things books, each contribution in this volume follows a nonrestrictive, open-source model. Each contribution is licensed under a Commons Attribution 4.0 License. Many of the contributions also first appeared on the 97 Things Medium publication.

All these things are fuel and fire for your thoughts and your code.

“Simple” Network Connections with Java – a problem

I've been playing with NIO for network stuff to see if/how I want to update the code for Head First Java 3rd Edition. The original code used Sockets and Readers/Writers, and I thought there must be a more "modern" way to do this so I've tried updating it a few different ways. I got it working using SocketChannel and ByteBuffer (eventually!), but the ByteBuffer stuff is just too fiddly to use to teach people basic network IO in Java. After turning to Twitter for the answers (Twitter Driven Development) I had what looked like a promising hybrid approach.

However, I've run into a problem with using the Channels factory methods to provide this nice bridge between NIO (SocketChannels) and classic streaming IO.

I'm posting the code here because you can't post source code this long on Twitter! Maybe someone can help me.

Continue reading "“Simple” Network Connections with Java – a problem"

Upgrading a Maven, Spring Boot and JavaFX application

I've been migrating all my JavaFX applications to Java 15 / JavaFX 15.0.1 to see if there are any pain points or gotchas to be aware of. I particularly wanted to understand how Maven and Gradle handle JavaFX, and how to successfully build and run the applications in IntelliJ IDEA.

In this blog post I explore the steps taking to upgrade a Spring Boot/Maven/JavaFX application.

Continue reading "Upgrading a Maven, Spring Boot and JavaFX application"

Upgrading a Modular Gradle JavaFX Application

You might think, particularly given the order in which I have posted these blog posts, that I tackled the easiest application first when I decided to upgrade my JavaFX applications. But no. Because I like to live life on Hard Mode.

I spent two full days last week once again tackling the on-going tech debt I had with a Modular JavaFX application. And I won! Yay! So here's my experience report.

Continue reading "Upgrading a Modular Gradle JavaFX Application"

Upgrading a Gradle JavaFX Application

I'm helping out a bit with an IntelliJ IDEA Live Stream on JavaFX, and I used that as an excuse to refresh my JavaFX knowledge. One of the things I did was make sure I upgraded all my existing applications to the latest versions of everything and make sure they work as expected.

I have what is now quite an old demo application, originally designed to showcase Java 8 features (watch the live demo and find out more). Since JavaFX was moved into the JDK in Java 8, I decided to use JavaFX as the UI. In fact, it's this demo that was the basis for all my later JavaFX applications, including the Spring Boot one.

I haven't done much with this for a loooong time, but it turns out I have been periodically updating dependencies and trying to make sure it all compiles. I highly recommend taking the time to do this at least once a year! It turns out that because I've been updating dependencies for the last 3-4 years that it wasn't that painful to bring it right up to date. In fact, I did it in less than 30 minutes!

Continue reading "Upgrading a Gradle JavaFX Application"

Creating JavaFX Applications

Hand drawing of a JavaFX Dashboard

This week we're doing a Live Stream on JavaFX, and I wanted to use that opportunity to refresh my JavaFX knowledge.

I wanted to investigate two areas in particular:

  • How do the changes in Java 11 (when JavaFX was moved out of the JDK) impact JavaFX applications?
  • How do I get a modern (Java 15) JavaFX application working as expected in IntelliJ IDEA (using either Maven or Gradle as the build tool)?

I now have six different applications that showcase JavaFX! And... they all have slightly different issues... sorry, I mean "subtleties around the best way to run them". Yes.

Continue reading "Creating JavaFX Applications"