Kotlin – Use EnumSet For RBAC

Enumset is a powerful collection in Java to replace bit fields. This article will explains how to use EnumSet to create a RBAC (Role-Based Access Control). Now, let’s see how we can use EnumSet to create a RBAC. Inside the setup method, a series of roles with specific access right in a given system has been defined... » read more

Java – Why you should use Optional

To Overcome NullPointerException The Java 8’s Optional is meant for alleviating the occurrence of NullPointerException. NullPointerException is the result of Null References, Null Reference is also known as The Billion Dollar Mistake. The Billion Dollar mistake was coined by a British computer scientist, Sir Charles Antony Richard Hoare. Null pointers are the single biggest source... » read more

Java – How to compare strings

== is to compare 2 object whether are of the same reference equality (whether they are the same object). .equals() tests for value equality (whether they are logically “equal”). Objects.equals() checks for null before calling .equals() so you don’t have to check null to avoid NPE. (available since JDK7, also available in Guava). String.contentEquals() compares... » read more

Java – What are Default Methods II

Prior to Java 8, Java interfaces cannot be implemented. Because of a class can implement more than 1 interface, and imagine in the event of there is same signature in different interfaces which the class is implementing, then in this case, the class might be confused to picking which one, cause in the past prior to... » read more

Java – How to Handle NullPointerException Effectively

NullPointerException is a common exception in Java-based applications. It is also known as Billion-Dollar mistake. NullPointerException is a sub-class of RuntimeException. A RuntimeException is an unchecked exception, it does not force you to use catch block to handle it. This article going to explain some approaches to handle NullPointerException effectively. Why NullPointerException occur in your... » read more

Java – What are Default Methods I

Java 8 brought a new capability known as default methods into Java interface. This articles guides you how to get the benefit from default methods in interface. Why Default Methods in Interfaces Are Needed Imagine in a situation where if one or more methods are added to the interface, then classes which implemented those interfaces... » read more

Python – Zen of Python

Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren’t special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the... » read more