I am using the jdbi library like so: This try catch pattern is repeated a few times, with various different queries passed to the jdbi.withHandle method. Another example: The jdbi.withHandle method has this signature: I am trying to find a way to reduce the duplication around the try-catch, so that I can use something like this instead: i.e. the handleTransientExceptions
Tag: refactoring
How do I refactor multiple if-else statements in Java?
How do I refactor all this code that seems repetitive and too long, is there a way to make it shorter? if (typeOfData.equals(“Book data”)) { System.out.println(lineOfText); Scanner …
Refactoring code that contains multiple if conditions
Here is some code I’ve written to save a UrlEntity : public UrlEntity saveUrlEntity(String longUrl, LocalDate dateAdded) { int urlLength = longUrl.length(); if (urlLength >= Constants….
Extracting multiple string to constant in Intellij IDEA
In my code, there are a lot of strings appeared in the following structure: I would like to extract the string key to a constant. However, doing this one by one will take forever…So, is there a better way to achieve this? Answer No idea in Intellij, but if your lines are genuinely that simple, you can do it with