Skip to main content


Showing posts from 2014

Thread Local Storage in Java

This post is part of the JavaAdventCalendar and is licensed under the Creative Commons 3.0 Attribution license. If you like it, please spread the word by sharing, Tweeting, FB, G+, etc!      
It was also republished under

One of the rarely known features in Java among developers is Thread-local storage. The idea is simple, and the need for it comes in  scenarios where we need data that is, well, local for the thread. For example, if we have two threads that refer to the same global variable but we want them to have separate values independently initialized of each other.
Most major programming languages have implementations of the concept. For example, C++11 has the thread local keyword, and Ruby has chosen an API approach.
Java has also an implementation of the concept with  java.lang.ThreadLocal<T> and with subclass java.lang.InheritableThreadLocal<T> since version 1.2, so nothing new and shiny here. Let…

How to Not Hate JavaScript: Tips from the Frontline

This article was originally published on voxxed under,

In my work assisting teams with JavaScript related problems, I’ve noticed some common issues. If you're experiencing frustrations with the language too, this article might be of some assistance. Disclaimer: a few of my tips might be obvious to some of you, but hopefully you’ll find at least some useful nuggets of information here! These pointers are especially useful when dealing with enterprise applications and CMS solutions. This is where we have our code, the CMS code, the code from that team nobody wants to mention...and, of course, all of them are loaded asynchronously.
The Debugger Statement
This is one of the most underused features when dealing with JavaScript, especially since it’s supported by the majority of browsers. The debugger statement was part of the first edition of ECMA Script so it's been here for quite some time.


Java2Days 2014: From JavaSpaces, JINI and GigaSpaces to SpringBoot, Akka – reactive and microservice pitfalls

This my 5-th year in a row where together with jugmk attend Java2days, a conference in Sofia, Bulgaria. While not so obvious from the name it is a 2-day java conference and currently the biggest one near us that we can take a bus to go to.
This year I had a talk titled "From JavaSpaces, JINI and GigaSpaces to SpringBoot, Akka – reactive and microservice pitfalls."
or buzz words and hate words all in one.

About the topic 
My talk this year was about microservices even though it had a long title with lots of strange words it was more of a concepts talk.
I gave a basic introduction into what reactive programming means for different people, the reactive manifesto and of course Microsoft Excel.
Next part was to define what microservies are and what they can be for different organization.
The Unix aspect of microservices had to be covered so I did just that.

My goal with the talks was not really to compare frameworks for this or that, but I just gave a short overview of what ideas…

Virtual Java User Group - simple concept with quality content

Virtual JUG is a simple concept based on the idea to organize a group that would generate quality content.
It is simpler to get technical leaders from around the world to present online and there are no travel cost concerns.  The intent is not to replace local JUG's but rather increase their value and also represent a sort of global JUG. Additionally it enables developers without an access to a local jug with a means to connect with many developers around the world.

Live sessions are streamed online and as chat ##virtualJUG on Freenode is used. But you don't have to trust my word for the quality of the content, here is a list of the past sessions: 
"Design is a Process, not a Document" by Trisha Gee"Drive by Contributions"­ A GitHub session by Brent Beer and Matthew McCullough"Don't be that guy! Developer Security Awareness" by Markus Eisele"Getting Started with Java EE 7" by Arun Gupta"How To Do Kick-Ass Software Development&quo…

*nix for developers

Unix and Linux in their various forms are everywhere. Werther you are working on some server-side application or mobile app at any stage it is very likely that it will use Unix at some point.
That is why at our company we decided to have a small introduction demo/discussion on some useful concepts and command line tools.
We also went through a high-level overview starting with initial with run level and job control.
While most of the demoing is not visible via the slides I decided to share the slides anyway:

Unix for developers from Mite Mitreski

Redneck conditional anti-pattern

Sometimes I encounter weird looking if statements. By weird, I'm thinking of multiple negations all over the code base. Just a few days ago together with my colleague we found them very exotic during debug of an external library. From this point on, I'll call the following anti-pattern redneck negation or "I ain't not going to do that".

 So let's take a look at a snippet:
if(!some_flag_that_means_off) { //handle negative scenario where we change the flag value } else { //handle positive scenario where we also change the flag value } //decide upon my flag The simpler version would be an extracted method with:
if(some_condition) { //return positive } else { //return negative } Now the code is easier to read and simpler to maintain.

State of mind You might be wondering how someone writes this or how we end up with this type of multiple negation codes. It is easy to judge people, but the reality is that this might have been done at some crazy pres…

[Book review] OAuth 2.0 Identity and Access Management Patterns

I accepted to do a review of the newly published OAuth 2.0 Identity and Access Management Patterns by Martin Spasovski. He is a friend of mine so with impartiality in mind it would be fail enough of me to give this information beforehand.

OAuth is the most widely known and used authorization framework. There are many service providers like Facebook and Twitter making it easy to connect with millions of users. From the users perspective is significantly simpler than remember and managing different passwords which is easily manipulated. The book make nice introduction to integration of OAuth 2.0 on web applications, desktop and mobile. It also covers various flows and a server side implementation using SpringMVC. While the examples throughout the book are clean one part really caught my attention :
tokenEndpoint .concat("?grant_type=client_credentials") .concat("&client_id=").concat(clientId) .concat("&client_secret=").concat(clientSecret) …

"Thou shalt not spam" or what are web notifications

Web notifications are one of the newer features added into modern browsers. They are intended as alerts for the user outside of the web page context. The idea is for them to be browsers and system independent, for example, when using a mobile browser notification could go into the home screen of the device. On the desktop usually they show up on the right-corner of the screen, at least on most desktop environments. They can be very annoying thing and you should think if thoroughly before you decide this is the right way to inform the users. There are some restrictions that avoid the creation of popup but I still have a bad feeling whenever I see one of these. One example of these notifications are the gmail/gtalk updates that show up on new messages (they are useful and annoying at the same time). This is done via the Notification API and we will do a simple example of its usage.The implementationFirst we can start with a simple wrapper for the Notification API that will have a fallba…

Run, JUnit! Run!!!

This blog post is crossposted and originally part of the 2013 edition Java Advent Calendar a lovely initiative from Attila-Mihaly Balazs and the Transilvania JUG 

JUnit together with JavaScript and SVN are some of the technologies that programmers often start using without even reading a single blog post let alone a book.  Maybe this is a good thing since they look simple enough and understandable so we can use them right away without any manuals, but this also means that they are also underused. In this article we will go through some features of JUnit that I consider very useful.

Parameterized tests  Sometimes we need to run the same method or functionality with many different inputs and different expected results. One way to do this would be to create separate tests for each of the cases, or you can use loop but that it would be harder to track down the origin of a possible test failure.

For example if we have the following value object representing rational numbers:

public class Ra…