Adding New Currency in Java 8

If you are using the java.lang.Currency as part of your entity, most likely you are already regretting it now. Most of the time, a currency is a three letter word, and we don’t need the logic to be bundled in there. Keeping things simple and mapping these currencies as a String or own custom class is the way to go. For people who did use java.lang.Currency, the pain will arrive when a country changed its currency or added a new one.
Read more →

Event Driven Architecture

Why do we need it? In the early stages of the development, event driven architecture is not needed since everything is still small and could still be contained in one place. Unfortunately, as the system grows bigger and bigger, putting everything in one place is not a very good way to scale (a.k.a monolith). The logic of the whole system will also keep increasing in complexity, and eventually there will arise the need to separate the giant system into domains.
Read more →

The Difference between For-Each Loop and forEach()

People who have played enough with the brand new Java 8 will be familiar with the new forEach(fn(x)) loop in lambda. This syntax is quite popular among developers because it’s easier and prettier to use than the normal For-Each loop. It is also popular in other languages, especially JavaScript. The problem is, I’ve seen a very specific bug, which is related to this “functional” forEach() loop, quite a few times, again and again.
Read more →

Java 8 - Turning off SSL Certificate Check

There’s usually no good reason to turn off SSL certificate check. So this is actually wrong in many ways, but maybe we’re still developing in an isolated dev environment and somehow the dev machine of another application you’re depending on only allows SSL connection even though it doesn’t have a valid certificate. The correct solution is actually to self sign a certificate or add it in the system, so that if your application go live, you will still have ssl certificate check turned on.
Read more →

Java Application Server is dead, so is Docker?

So lately, a lot of people in my circle is talking about why java application server is dead. The reason why is explained in the slides here. Basically what I get is that because nowdays people only deploy one artifact in one application server, it beats the point of the application server. It’s more like that the application server is already part of the application. So, it would be better to treat the application server as part of the application and ship them together as a package.
Read more →

Hibernate Soft Delete and Optimistic Locking Problem

Sometimes, in the database, we will want to not delete stuff because the data might still be needed later. Maybe some other process in the company will have to generate an invoice by the end of the month. That’s also one of the reason in my workplace, why there won’t be any hard delete in the database except when we’re sure it’s really necessary. One solution for this, in hibernate, is to overwrite the sql delete command using the @SqlDelete annotation:
Read more →

Factorial function of 10000!

I have a friend who asked me to teach him Java programming. About a few days ago, he told me : Programmers should work fast and efficient. Please give me a task which has a time limit. I’m not used to fast programming. The part about fast and efficient is always universally true. It doesn’t apply to only programming, but I am more in the direction of doing something right instead of fast.
Read more →