Skip to main content

Posts

Using Drools to Dynamically Manipulate Metadata of JSF Components

The post is just an approach to change metadata (e.g maxlength, required, etc) of JSF components (e.g. inputText, selectOneMenue, etc) by Drools. Project structure Tools being used Java version 1.8.0_131 Apache Maven 3.5.0 Apache Tomcat 8.0.16 Don't forget to configure your confidential information on  these following files: pom.xml, settings.xml (Maven) and tomcat-users.xml (Tomcat). For example: Source code https://github.com/vnnvanhuong/java_lab/tree/master/jsfdrools

Coding Exercise, Episode 1

I have received the following exercise from an interviewer, he didn't give the name of the problem. Honestly, I have no idea how to solve this problem even I have tried to read it three times before. Since I used to be a person who always tells myself "I am not the one good at algorithms", but giving up something too soon which I feel that I didn't spend enough effort to overcome is not my way. Then, I have sticked on it for 24 hours. According to the given image on the problem, I tried to get more clues by searching. Thanks to Google, I found a similar problem on Hackerrank (attached link below). My target here was trying my best to just understand the problem and was trying to solve it accordingly by the Editorial on Hackerrank. Due to this circumstance, it turns me to love solving algorithms from now on (laugh). Check it out! Problem You are given a very organized square of size N (1-based index) and a list of S commands The i th command will follow t

How Would You Answer These Typical Interview Questions?

I have joined several job interviews with candidates at my current company. As a technical supporter, my attention was mainly focused on specific technical points rather than behavioral ones. However, I saw that these following  typical   questions  were rarely missed for any interviews. In fact, there is a meaning behind of the questions.  The concern is candidates should focus on answering the right things that interviewers really want to know. Take a look! Introduce about yourself It is "What and why are you fit for this job?".  So, it is good to go "Talking too much about your hobbies."? I would say "We don't care about your hobbies much". ;) Why do you want to find a new job? It is "Why this job are interesting you?".  So, it is good to go "Talking about something negative like 'I hate my boss/leader'"? I would say "Who wants to work with a negative person?" What did you do in your current j

Building an App for Removing Multiple Slack's Files

You're a developer. What do you do in your spare time? One of my most excited task for sharpening my skills is starting build a pet project. Motivation Slack is cool! It's free. It supports for team collaboration very well. However, my team only has storage limits due to a free account. We got a warning message as below: Your file was uploaded — it’s safe and sound in Slack. Unfortunately your team doesn’t have any storage space left. To get more space, you can upgrade to a paid account or delete some of your older files. Since my team plan of upgrading to a paid account is still up in the air, I intended to go with "deleting some of our older files" first. (But we will, Slack. You are great!) Play Around I got started by googling keyword "remove slack files". Here it is: https://get.slack.help/hc/en-us/articles/218159688-Delete-shared-files Uh huh! But I only could delete one file at a time . We're afraid it's not possible t

Multiple Inheritance of State and Implementation

Today, I was just curious about why an enum can not extend anything else. I took a look on the Oracle document here , and I found the answer is below: "All enums implicitly extend java.lang.Enum. Because a class can only extend one parent (see Declaring Classes), the Java language does not support multiple inheritance of state (see Multiple Inheritance of State, Implementation, and Type), and therefore an enum cannot extend anything else." I have been learned of it before. But, wait a sec...! Why Java does not support multiple inheritance of state? Since I have worked with other programming languages like C++, I was able to make a class extend some other classes. The short answer is to avoid the issues of multiple inheritance of state .  I wonder if other programming languages have these below terms but Java does. Multiple inheritance of state It is the ability to inherit fields from multiple classes. There is a problem and Java avoids it. "For exa

Why Business Rules Engine Matter

"A good DSL minimizes the 'communication gap' between a domain concept and the code that implements it" - Robert C. Martin A Use Case It looks like adopting a new technology is always driven by a business need. The organizations, such as banks, have their own business processes (such as data gathering and document management). These processes are different from others but usually the differences are not big. How do we build a product which can be reused the similar features but still be adaptable with the specific requirements of each bank? Then, the answer is we should have a library/framework. There is an idea that we can implement this library/framework by using a business rules engine. Which has the following benefits: Be able to modify implementation of business domain at runtime (such as XML, CSV) S ource code is more readable for both developers and domain experts. Therefore, source code can be consider it as a document Since Business Rules Engine

Template Method Pattern: Don't Call Us, We'll Call You!

So far, the Template Method has been my most used design pattern. That is the reason why this post is quite long. J Definition from Wiki The Template Method defines the program skeleton of an algorithm in a method, deferring some steps to subclasses. It lets one redefine certain steps of an algorithm without changing the algorithm's structure. A Real World Use Case Imagine that you have many different kinds of documents. You want to generate a pdf file from a corresponding word template. Each type has its own small modifications but the main process for document generating is the same. We apply the Template Method for this case. We define a final method including some steps (such as preparing for content, generating file) at a superclass. There are three possibilities for these steps at subclasses: Must be overridden: abstract methods. Not mandatory to be overridden: default protected methods. Can not be overridden: default private methods. Dissecting the Patt