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"

Speaker Tips – Bootstrapping Conference Speaking

Photo of Trisha and Daniel presenting at Devoxx

I have loads of advice for aspiring speakers, which is lucky because I get asked about how to get started (or how I got started) all the time. I found an email I sent to someone absolutely years ago (2014) and thought it useful enough to dust off and post. It's interesting to see my mindset back then because now I've largely forgotten what it was like in the early days.

The timing is not great, since in these Coronavirus times no-one's going to or presenting at conferences, but I firmly believe that with all these virtual events and conferences there's a much lower barrier to entry to speaking, and that now is exactly the right time to start presenting if it's something you've ever had on your wish list.

"I was hoping I could get some advice off you as I'm starting to look at ways to get out and speak a little bit more at events. Would you have some insights from how you started?"

Continue reading "Speaker Tips – Bootstrapping Conference Speaking"

Speaker Tips – What to Wear

For years I’ve avoided talking about the topic of what to wear when presenting. I didn’t want to cover it because I didn’t want people to think that I only worried about this topic because I was a woman. I also didn’t want other women to inherit any of my neuroses around deciding what to wear. I’m the sort of person who always enjoyed thinking long and hard about what to wear the next day at work, and I know that’s not how everyone works.

Continue reading "Speaker Tips – What to Wear"

Speaker Tips – Wearing a Roaming Mic is More Complicated Than I Realised

Photo of Trisha presenting at Devoxx

I realise I have a bunch of experience and advice for speakers and potential speakers that I simply haven’t written down or shared. Here’s the first piece on things to consider that you might not have thought about.

Note: as usual, my advice is from the point of view of a woman (me) and is aimed mostly at women, but also as usual it’s probably useful for others to know too.

Continue reading "Speaker Tips – Wearing a Roaming Mic is More Complicated Than I Realised"

New IntelliJ Tricks I Learnt Part 2

Apparently, I’m all about Continuous Learning - after I wrote the last post about IntelliJ Tips, I carried on through my trawl of the documentation and, of course, discovered a load more things I didn’t know. And this is all just in the Quick Start section!

So here’s the next batch (although once again I’m not sure how many are only applicable to IntelliJ 14). All shortcuts are for Windows unless otherwise stated, and Mac users should be able to replace the Ctrl key with Cmd in all these cases.

Navigate between methods

Now I knew you could use the structure thingie (Ctrl+F12) to let you navigate to methods in your class (although I never actually use it, it somehow never sticks in my head). What I did not know is that you can jump between methods using Alt+Up/Down arrows. This strikes me as being super useful, especially to browse tests.

Refactoring String Fragments

I’ve wanted this feature so many times, but could never find it or get it to work - did you know you can refactor out parts of a hardcoded string into variable/field/constant? Select the section of the String you want to extract, and use the normal “Extract…” shortcuts - e.g. Ctrl+Alt+V to extract it into a variable.

I’m sure I’ve tried this before and it didn’t work. But I’ve tested it and it does!

Invert Boolean

There doesn’t seem to be a keyboard shortcut mapped by default, but using “Refactor -> Invert Boolean…” (or using our newly discovered “Navigate to Action” shortcut of Shift+Ctrl+A and typing “Invert”) you can tell IntelliJ you want a boolean field to mean the opposite thing, and it will flip the meaning everywhere. For example, you might have an saved flag, and you now want it to mean notSaved - IntelliJ will make sure the isSaved method returns !notSaved.

Magic Refactor Suggestions

You don’t always know exactly what refactoring operation you want to perform, and IntelliJ is ready to help - it can suggest refactorings available in the current context using the catchy magic incantation Ctrl+Shift+Alt+T. Seems useful, but I’m pretty sure I’m not going to remember that one.

Highlight implemented/overridden methods

I love everything about IntelliJ’s ability to find usages of things - finding where methods are called, finding implementations of a method, highlighting usages of a field, method or variable… What I didn’t know, is that you can highlight the methods that implement or override a specific interface or superclass. For some people, this might not add much, as your little “I override something” icon

"Overrides

combined with the @Override annotation, might tell you all you need to know. But that only really works if you’re implementing a a single interface. If you’ve correctly separated your concerns, you might implement several interfaces, and want to know which are the methods from a particular one. That’s where Shift+Ctrl+F7 on the “extends” keyword comes in handy.

Run individual inspection by name

I use inspections quite a lot. They’re especially useful if you have a codebase that doesn’t quite conform to your ideal standards, so you can’t yet turn on automated checks like checkstyle to break the build when the code doesn’t conform - there’s an initial step where first you need to clean up the code. Inspections are great, because you can have IntelliJ give you little yellow marks to show where things are suboptimal, and aim to check in only files without little yellow marks.

What I didn’t know, is that you can run a single inspection on files in any scope. So if, for example, you wanted to make sure that the code you’ve touched in this change has no unused bits, like unused parameters or unused/untested methods, you could press Shift+Alt+Ctrl+I and type “unused”. Select the “Unused Declaration” inspection and choose to run this on all uncommitted files. This will tell you where you can clean up your code, and every commit should make your codebase that little bit better.

Saving Power With Highlighting

I did not know you could easily alter the active errors/warnings, and use that to save power. Quite Interesting.

Auto indent your lines

I almost obsessively reformat my code as I go, pressing Ctrl+Alt+L almost like a muscle twitch. What I’ve just discovered, though, is that there’s a shortcut which will just fix the line indentation, which is probably 80% of what I need anyway - Ctrl+Alt+I.

Fix Evil String Concatenation

I can’t believe I didn’t notice this one earlier - do you know how many times I’ve gone around and manually changed:

System.out.println("This thing " + something + " is " + somethingElse); 

to

System.out.printf("This thing %s is %s%n", something, somethingElse); 

Do you??? Anyway you don’t need to - Alt+Enter inside the params will suggest the replacement and do it for you. Nice.

VCS Quick Access

One of the areas where I definitely don’t use IntelliJ to the best of its abilities is the Git integration. I’ve been using SourceTree combined with IntelliJ to do most of my VCS management (I’m so sorry, I’m just not a command line person, I need to actually see it). With the new laptop, I haven’t installed SourceTree yet and I’m going to try and do everything via the IDE. Previously I used the right-click menu mostly for managing VCS operations, occasionally the VCS menu, and did most stuff in the “Changes” window. But now I’ve discovered Alt+"Back Quote” (Ctrl+V on the mac) to bring up the menu of git-shaped operations for this context. To stop you having to hunt all over the keyboard to find what on earth a “Back Quote” is, it’s `, which on both my UK and US (Windows) keyboards is in the top left corner of your keyboard (on the Mac, it’s on the bottom left next to the shift, but you shouldn’t need it since your shortcut is different anyway).

Amend Commits

I’ve just discovered that you can commit a change which smushes up into your last commit and fixes it. I’m assuming it commits the new changes and (potentially) an updated commit message into the last change. I really wish I’d known about this earlier, on a number of occasions in the last few months I’ve done this either manually or by doing a rather dangerous soft reset. I will definitely be using this in the future.

"Amend

The Cursor as a Breakpoint

Did you know that you can use the cursor as a temporary breakpoint? I did not. Well, now you know.

Labelling Changes

I hope by now none of us developers are doing that icky thing of having “Copy of…” and “Backup of…” filenames and directories to keep track of our versions. We’re all using a VCS of course. But if you’re being strict about making sure that every commit leads to a working build (we all do that, right…?) then sometimes even distributed file systems like git, with its local branches, are too heavyweight for experiments and debugging.

IntelliJ has Local History, which I personally think you should never rely on, but has occasionally saved my bacon in times of strife. It also does this really nice thing (automatically) where it labels versions where the tests passed, so you’ve got some level of confidence that at that point in time, at that revision, things weren’t hideously broken. At the very least, they must have compiled. What I did not know is that you can add your own labels, so you could label some local, non-committed version of the file as “feature x works but y doesn’t” (or probably something much shorter).

I think it looks useful. As I say though, not a replacement for VCS, but a suppliment.

So, that's the end of Week One at JetBrains, and already I've learnt a whole heap of things. I'm sure there's more to come, so stay tuned!