For the last few months I am in a Java project where we are using Javaslang library. As a result I have posted a short demo of Try capabilities on my company’s website “Road to a more functional Java with Javaslang – example refactoring”. If you are not familiar with Try, this is a short, but conrete explanation from their javadoc:

Try is a monadic container type which represents a computation that may either result in an exception, or return a successfully computed value. It’s similar to, but semantically different from Either. Instances of Try, are either an instance of Success or Failure.”

For more details describing how Try could be used to simplify your code, please read the post mentioned above.

Contest – win a ticket to GeeCON

After several discussions with people who pointed me out that actually code presented in that blog post is not perfect and could be improved, we have decided to organize a small contest so people could show us their Java code doing the same thing as our class. This way we coould see how this logic could be implemented using different approaches, what is most important, we could also learn form others 🙂 So let me introduce “Show your Java refactoring” contest:

If you skip all law-related stuff rules are pretty simple: write a code that does the same thing as our original FacebookImage class:

  • Load the content of a website
  • Extract the first og:image from the meta tag in <head> section
  • Return a URL of this image
  • If there is no such page, in case of any exception or if there is no og:image, log a warning and return a URL of a default image as a fallback.

Then send a Pull Request and (if your code is good enough) win a ticket to GeeCON 2017. For a complete description, rules, etc. please go to the announcement on our webpage, everything is described in a more detail there. From my, personally, I can not wait to see and analyze solutions from other Polish developers and learn new tricks along the way 🙂