<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Java on Rowanto Luo</title><link>https://log.rowanto.com/categories/java/</link><description>Recent content in Java on Rowanto Luo</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Thu, 17 Nov 2016 01:50:48 +0000</lastBuildDate><atom:link href="https://log.rowanto.com/categories/java/index.xml" rel="self" type="application/rss+xml"/><item><title>Adding New Currency in Java 8</title><link>https://log.rowanto.com/posts/adding-new-currency-in-java-8/</link><pubDate>Thu, 17 Nov 2016 01:50:48 +0000</pubDate><guid>https://log.rowanto.com/posts/adding-new-currency-in-java-8/</guid><description>
&lt;p&gt;If you are using the &lt;code&gt;java.lang.Currency&lt;/code&gt; 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&amp;rsquo;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.&lt;/p&gt;
&lt;p&gt;For people who did use &lt;code&gt;java.lang.Currency&lt;/code&gt;, the pain will arrive when a country changed its currency or added a new one. As example, Belarus changed its currency from BYR to BYN at July 1st, 2016. If you are using &lt;code&gt;java.lang.Currency&lt;/code&gt;, you prolly already know by now that &lt;code&gt;Currency.getInstance(&amp;quot;BYN&amp;quot;)&lt;/code&gt; will throw you an exception. Most likely you have also google around, and most likely again, you will stumble upon &lt;a href="http://stackoverflow.com/questions/9982537/how-do-i-add-the-new-currency-code-to-java"&gt;this&lt;/a&gt; or &lt;a href="http://docs.oracle.com/javase/7/docs/technotes/guides/intl/enhancements.7.html#currency"&gt;this&lt;/a&gt;. It&amp;rsquo;s basically telling you that there is this new feature in java 7, which lets you overwrite the currency. You will happily overwrite BYR to BYN, and now it starts working. This happyness doesn&amp;rsquo;t last long as you realize that now that you support BYN, but not BYR anymore. You might also stumble upon some pages which write that we can&amp;rsquo;t support both currency at the same time.&lt;/p&gt;</description></item><item><title>Event Driven Architecture</title><link>https://log.rowanto.com/posts/event-driven-architecture/</link><pubDate>Thu, 09 Jun 2016 23:35:11 +0000</pubDate><guid>https://log.rowanto.com/posts/event-driven-architecture/</guid><description>
&lt;h2 id="why-do-we-need-it"&gt;
Why do we need it?
&lt;a href="#why-do-we-need-it" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item><item><title>The Difference between For-Each Loop and forEach()</title><link>https://log.rowanto.com/posts/the-difference-between-classic-foreach-and-java-8-functional-foreach-loop/</link><pubDate>Wed, 06 May 2015 17:06:16 +0000</pubDate><guid>https://log.rowanto.com/posts/the-difference-between-classic-foreach-and-java-8-functional-foreach-loop/</guid><description>
&lt;p&gt;People who have played enough with the brand new Java 8 will be familiar with the new &lt;a href="https://docs.oracle.com/javase/tutorial/collections/streams/"&gt;forEach(fn(x))&lt;/a&gt; loop in lambda. This syntax is quite popular among developers because it&amp;rsquo;s easier and prettier to use than the normal &lt;a href="https://docs.oracle.com/javase/1.5.0/docs/guide/language/foreach.html"&gt;For-Each&lt;/a&gt; loop. It is also popular in other languages, especially JavaScript.&lt;/p&gt;
&lt;p&gt;The problem is, I&amp;rsquo;ve seen a very specific bug, which is related to this &amp;ldquo;functional&amp;rdquo; forEach() loop, quite a few times, again and again. People tend to think that these two kinds of loop are 100% identical, which is not. Although Java 8&amp;rsquo;s type-safety make it harder for people to make this mistake because of its compilation error, it&amp;rsquo;s still not 100% safe.&lt;/p&gt;</description></item><item><title>Java 8 - Turning off SSL Certificate Check</title><link>https://log.rowanto.com/posts/java-8-turning-off-ssl-certificate-check/</link><pubDate>Sat, 21 Mar 2015 09:11:56 +0000</pubDate><guid>https://log.rowanto.com/posts/java-8-turning-off-ssl-certificate-check/</guid><description>
&lt;p&gt;There&amp;rsquo;s usually no good reason to turn off SSL certificate check. So this is actually wrong in many ways, but maybe we&amp;rsquo;re still developing in an isolated dev environment and somehow the dev machine of another application you&amp;rsquo;re depending on only allows SSL connection even though it doesn&amp;rsquo;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. If not, you might forgot to turn the ssl certificate check back on when launching the stuff and it will be bad. So, use this on your own risk.&lt;/p&gt;</description></item><item><title>Java Application Server is dead, so is Docker?</title><link>https://log.rowanto.com/posts/java-application-server-is-dead-so-is-docker/</link><pubDate>Tue, 16 Sep 2014 09:00:00 +0000</pubDate><guid>https://log.rowanto.com/posts/java-application-server-is-dead-so-is-docker/</guid><description>
&lt;p&gt;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 &lt;a href="http://de.slideshare.net/ewolff/java-application-servers-are-dead"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;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&amp;rsquo;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.&lt;/p&gt;</description></item><item><title>Hibernate Soft Delete and Optimistic Locking Problem</title><link>https://log.rowanto.com/posts/hibernate-soft-delete-and-optimistic-locking-problem/</link><pubDate>Tue, 11 Feb 2014 11:00:00 +0000</pubDate><guid>https://log.rowanto.com/posts/hibernate-soft-delete-and-optimistic-locking-problem/</guid><description>
&lt;p&gt;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&amp;rsquo;s also one of the reason in my workplace, why there won&amp;rsquo;t be any hard delete in the database except when we&amp;rsquo;re sure it&amp;rsquo;s really necessary.&lt;/p&gt;
&lt;p&gt;One solution for this, in hibernate, is to overwrite the sql delete command using the @SqlDelete annotation:&lt;/p&gt;</description></item><item><title>Factorial function of 10000!</title><link>https://log.rowanto.com/posts/factorial-function-of-10000/</link><pubDate>Fri, 10 May 2013 09:00:00 +0000</pubDate><guid>https://log.rowanto.com/posts/factorial-function-of-10000/</guid><description>
&lt;p&gt;I have a friend who asked me to teach him Java programming. About a few days ago, he told me :&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Programmers should work fast and efficient. Please give me a task which has a time limit. I&amp;rsquo;m not used to fast programming.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The part about fast and efficient is always universally true. It doesn&amp;rsquo;t apply to only programming, but I am more in the direction of doing something right instead of fast. It&amp;rsquo;s better to do it right, but slow, instead of fast, but horrible. Of course it&amp;rsquo;s depending of the context also, but generally it should be like that in my opinion.&lt;/p&gt;</description></item></channel></rss>