Skip to main content

Posts

Showing posts from 2017

Git Feature Branch Workflow

Motivator It's important for a team to have an agreement on how the changes of source code should be applied.
According to projects and teams size, we will define a workflow or select one from recommended workflows; the "Feature Branch Workflow" is a candidate.
What is it? - One branch "master" for main codebase
- Several separated branches for features development
Why should we care? - Be super simple and allow each developer works on a particular feature.
- A stable codebase (master) benefits for continuous integration (CI) environment
- Leverage "Pull request" for Code review
How it works? A lifecyle of a feature branch (usually created by a story)
1. Creator creates a new branch from a story.  For example: "ABC-1-setup-projects"
2. Creator checkouts the created branch and works on the branch (commits, pushes)
3. Creator has done the feature, he uses "pull request" to merge his branch into branch "master"
4. Reviewers…

The 2017 Scrum Guide, and My Notes

https://www.scrum.org Scrum is not only designed for software development Scrum can be used for addressing any complex issues:
1. Research and identify viable markets, technologies, and product capabilities;
2. Develop products and enhancements;
3. Release products and enhancements, as frequently as many times per day;
4. Develop and sustain Cloud (online, secure, on-demand) and other operational environments for product use; and,
5. Sustain and renew products.
Scrum Values is a key factor for building trust and respect among team members The five values are:
1. Commitment
2. Courage
3. Focus
4. Openness
5. Respect
Daily Scrum's questions are more focused on inspection and adaption rather than the status 1. What did I do yesterday that helped the Development Team meet the Sprint Goal?
2. What will I do today to help the Development Team meet the Sprint Goal?
3. Do I see any impediment that prevents me or the Development Team from meeting the Sprint Goal?
Why Scrum still needs Scru…

Building Axon.ivy Projects on Bitbucket Pipelines

Read me if you don't know what Axon.ivy (Ivy) is.
Motivation - Ivy projects are designed to be built on a continuous integration (CI) server like Jenkins
- Today, Bitbucket supports for CI with Bitbucket Pipelines
- We're using Bitbucket. Then, why not? It must be very cool and convenient for us if we can centralize our CI and VCS (version control system) tools in one place.
Here is an approach We have to use a maven plugin called project-build-plugin to build ivy projects. This plugin requires an instance of Ivy engine during building time.
Bitbucket Pipelines allows us to specify our own docker image as a build environment. What we need to do  is to prepare our docker image with needed stuffs such as JDK, Maven, Ivy engine, etc. Step 1. Prepare Docker images For testing purpose, I already created two docker images: Maven and Axon.ivy engine. They are now available on Docker Hub

This image for Maven using Oracle JDK 8
This image for Axon.ivy Engine 7.0.1

Step 2. Configure Maven…

Java 8 - Persistent data structure

The following is a series of posts about "functional programming in Java" which is the result of my understanding by reading the book "Java 8 in Action: Lambdas, Streams, and Functional-style Programming, by Alan Mycroft and Mario Fusco".
1. Why functional programming?
2. Functional programming in Java 8
3. Java 8 - Using Functions as Values
4. Java 8 - Persistent data structure
Persistent data structure is also known as a simple technique but it's very important. Its other names are functional data structure and immutable data structure.
Why is it "persistent"? Their values persist and are isolated from changes happening elsewhere. That's it!
This technique is described as below:

If you need a data structure to represent the result of a computation, you should make a new one and not mutable an existing data structure.

Destructive updates version
public static A doSomething(A a){ a.setProp1("new value"); return a; }
Functional versi…

JSF, Primefaces - Invoking Application Code Even When Validation Failed

A use case I have a form which has requirements as follow:
- There are some mandatory fields.
- Validation is triggered when changing value on each field.
- A button "Next" is enable only when all fields are entered. It turns to disabled if any field is empty.
My first approach I defined a variable "isDisableNext" at a backend bean "Controller" for dynamically disabling/enabling the "Next" button by performing event "onValueChange", but, it had a problem:
<h:form id="personForm"> <p:outputLabel value="First Name" for="firstName"/> <p:inputText id="firstName" value="#{person.firstName}" required="true"> <p:ajax event="change" listener="#{controller.onValueChange}" update="nextButton"/> </p:inputText> <p:outputLabel value="Last Name" for="lastName"/> <p:inputText …

Java 8 - Using Functions as Values

The following is a series of posts about "functional programming in Java" which is the result of my understanding by reading the book "Java 8 in Action: Lambdas, Streams, and Functional-style Programming, by Alan Mycroft and Mario Fusco".
1. Why functional programming?
2. Functional programming in Java 8
3. Java 8 - Using Functions as Values
4. Java 8 - Persistent data structure
In general, the phrase "functional-style programming" means the behavior of functions should be like that of mathematical-style functions - no side effects.

In programmers' point of views, functions may be used like other values: passed as arguments, returned as result, and stored in data structures. That means we can use the :: operator to create a method reference, and lambda expressions to directly express function values. For example:
//method reference Function<String, Integer> strToInt = Integer::parseInt; //lambda expression Comparator<Integer> comparator =…

Functional programming in Java 8

In my previous post, we discussed about why we should consider to use functional programming. Now, let's delve into what functional programming in Java is.
What is pure functional programming?Shortly, functional programming is programming using functions. A function corresponds to a mathematical function such as log, sin. Basically, it takes zero or more arguments, give one or more result, and has no side effects.
We can't completely program in pure functional style in Java Why?  For example, calling Scanner.nextLine twice typically gives different result.

So, it's just called "functional-style programming". How is that?
- There is no mutating structures visible to callers. That means your side effect may not be visible to a program, but it's visible to the programmer in terms of slower execution.
- A function or method shouldn't throw any exceptions (follows the concept "pass arguments, return result"). We can use types like Optional<T> i…

Small Changes to Java 7 via Project Coin and Why They are Useful

Did you know how new features were added into Java 7? The following are functionalities that can be considered.
Source: [1] Project Coin is all about the changes in the range from syntactic sugar to new language feature. This is what we're talking about today.

Since Java 7 is the first version developed in an open source manner, there is an amount of actions that must be performed for any changes as follows:
Update the Java Language Specification (JSL)Implement a prototype in the source compilerAdd library support essential for the changeWrite tests and examplesUpdate documentEtc, ... Project Coin has submitted a lot of proposals (almost 70) but only some of them are chosen to Java 7. Why? Briefly, Java is a rich static type system and it has a lot of possible interaction points between different bits of it. Making changes to this type system is prone to creating unexpected surprises.

Wow! It is tough, right? Let's take a look what features Project Coin brought to Java 7.
Strings…

Climbing Fansipan – Highest Peak of Indochina

Fansipan is a mountain in Vietnam, the highest in Indochina, at 3,143 metres. It is located in the Lào Cai Province of the Northwest region of Vietnam, 9 km southwest of Sa Pa Township in the Hoang Lien Son mountain range. Wikipedia
Currently you can get the peak by cable car; however, I loved to explore it by climbing.

Here are what I have learned from this exciting journey. 💪
Do not procrastinate I have had no experience of climbing a high mountain before. Then, I've sought advice from my friends, but they suggested that I should not make it at that time due to bad weather and lack of experience. I know it never come true unless I just make my decision. Can't wait! Prepare for your journey You firstly need getting to know about the journey, schedule, transportation, etc. Recommended sources: YouTube videos, blog posts and tour companies websites.
Tips - Quality hiking shoes helps a lot - Bring your stuffs as light as possible. Important stuffs: a light raincoat and water (t…

Java Core - Top 10 Questions Every Developer Should Know

#RandomlyPickedByMe

What is the difference between Javascript and Java?Difference between StringBuilder and StringBuffer?Why do I get "SomeType@a3fde" when I print my code?Why is String immutable?Why "equals" method when we have "==" operator?Is List<Dog> a subclass of List<Animal>?Why shouldn't we use raw type?Is Java “pass-by-reference” or “pass-by-value”?What's the advantage of a Java enum versus a class with public static final fields?Why "double x = 0.1 + 0.2" and result of print(x) is 0.30000000000000004?
1. What is the difference between Javascript and Java? Holy crap! (Vietnamese: Thế quái nào lại có câu hỏi ngớ ngẩn vậy chứ?)

"Java and Javascript are similar like Car and Carpet are similar." - Greg Hewgill (on StackOverflow)
2. Difference between StringBuilder and StringBuffer String is immutable. StringBuilder and StringBuffer are mutable. StringBuffer is thread-safe. StringBuilder is modern than StringBuff…

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 usedJava version 1.8.0_131Apache Maven 3.5.0Apache 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 codehttps://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 ith command will follow the format (a[…

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 typicalquestions 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 yourselfIt 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 job?It is "Tell us wha…

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. MotivationSlack 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 to bulk delete files. We kn…

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 stateI 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 example, suppose that you are…

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)Source code is more readable for both developers and domain experts. Therefore, source code can be consider it as a document Since Business Rules Engines support for Do…

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 an 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 document. 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 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 Pattern Simply, we can see the f…

DevOps for Dummies

Everyone talks about it, but not everyone knows what it is.
Why DevOps? In general, whenever an organization adopts any new technology, methodology, or approach, that adoption has to be driven by a business need.

Any kind of system that need rapid delivery of innovation requires DevOps (development and operations). Why?
DevOps requires mechanisms to get fast feedback from all the stakeholders in the software application that's being delivered.DevOps approaches to reduce waste and rework and to shift resources to higher-value activities.DevOps aims to deliver value (of organization or project) faster and more efficiently. DevOps Capabilities The capabilities that make up DevOps are a broad set that span the software delivery life cycle. The following picture is a reference architecture which provides a template of a proven solution by using a set of preferred methods and capabilities.

My Remarks Okay, that sounds cool. What does it simply mean, again? The following is a simple case…

Google I/O 2017 Notes

WOW! How meaningful this below video explains about the name of  "I/O".
Sundar Pichai talked a lot of Machine Learning Machine Learning is a very hot trend these days. Google uses it for their products.
Google Assistant: Easily booking an online meal by talking with Google Assistant like a staff of partners, for example.Google Home: Hands-free calling.Google Photos: sharing suggestion, shared library, photo books and google lens.Youtube: 360 degree video, live stream. Kotlin became an official programming language for Androidhttps://kotlinlang.org

I'm on the way to Kotlin! ^^


Reference:
[1]. https://www.youtube.com/watch?v=Y2VF8tmLFHw

Why Functional Programming Matter

What issues do we concern when implementing and maintaining systems? One of the most concern is debugging during maintenance: "this code crashed because it observed some unexpected value."

Then, it turns out that the ideas of no side effects and immutability, which functional programming promotes, can help.
Shared mutable data is the root cause Shared mutable data are read and updated by more than one of the methods. Share mutable data structures make it harder to track changes in different parts of your program.

An immutable object is an object that can't change its state after it's instantiated so it can't be affected by the actions of a function. It would be a dream to maintain because we wouldn't have any bad surprises about some object somewhere that unexpectedly modifies a data structure.
A new thinking: Declarative programming There are two ways thinking about implementing a system by writing a program.

- Imperative programming: has instructions that …

Agile Design

How can you design the software which is built in tiny increments?

How can you ensure that the software has a good structure which is flexible, maintainable and reusable?

ARE'NT YOU GOING TO MISS THE BIG PICTURE?

Not really! In an agile team, the big picture evolves along with the software.

How? With each iteration, the team improves the design of the system so that it is as good as it can be for the system as it is now. They focus on the current structure of the system, making it as good as it can be.
How do we know if the design of software is good? Avoiding these following symptoms of poor design (design smells) should be a way.

1. Rigidity - The design is hard to change.
2. Fragility - The design is easy to break.
3. Immobility - The design is hard to reuse.
4. Viscosity - It is hard to do the right thing.
5. Needless Complexity - Overdesign
6. Needless Repetition - Mouse abuse
7. Opacity - Disorganized expression

These symptoms are similar in nature to code smells, but they ar…

Installing NGINX on macOS

I have heard of a lot of NGINX recently. One of them was it can help for security issues; for sure, it much be more. It so happens that our team has got a ton of user stories from a security audit. It's time to delve into it.
What is NGINX? In order to get a basic idea and have some fun, I've just picked some available posts from my favorite Vietnamese blogger communities as below:
https://kipalog.com/posts/Cau-hinh-nginx-co-ban---Phan-1https://viblo.asia/hoang.thi.tuan.dung/posts/ZabG912QGzY6 NGINX (pronounce: Engine-X) is a web server (comparing to IIS, Apache). It can be used as a reverse proxy (this is what I need for security issues with configuration), load balancer and more.
How to get started? I found the below path for learning NGINX by googling "learn nginx":
https://www.quora.com/What-are-some-good-online-resources-to-learn-Nginx In this post, I only went first step. This is installing NGINX on macOS and taking a first look at the configuration.
Installing …

Today I Learned - Git at First Glance

Getting Started It's always fun to jump right in to the "HelloWorld" app. Just go for it!

Visit: https://try.github.io/levels/1/challenges/1
Cheatsheet It's time for us to store our "magic tools".



Visit: https://www.git-tower.com/blog/git-cheat-sheet
Which collaboration way fit your team? Git is just a tool which doesn't teach you how to work properly in a team. It depends on your projects and you need to choose your own team workflow.

Visit: https://www.atlassian.com/git/tutorials/comparing-workflows

Make Our Code More Testable with Proxy Design Pattern

If you heard about the term separation of concerns, you could agree this concept is very important for making a system "clean". One of the most important characteristics of a clean system is testable.

Let me tell you my story about how I've just come acrosss the design pattern Proxy.

Note: to get started, you can find a very simple example of the pattern Proxy here
Let's start! I have an interface as below:
public interface DocumentGenerator { File generate(Document document) throws BusinessException; }
The following is my first implementation for a concrete class of DocumentGenerator.
public class DocumentGeneratorImpl implements DocumentGenerator { private Dossier dossier; private Locale locale; public DocumentGeneratorImpl(Dossier dossier, Locale locale) { validateNotNullParams(dossier, locale); this.dossier = dossier; this.locale = locale; } private void validateNotNullParams(LibertyDossier dossier, Locale locale) { if(Objects.isNull(dossier…

Separate Constructing a System from Using It

In the real world, in order to use a building (hotel, supermarket, etc) we need to construct it first. This concern should be applied for software development as well.

Step by step, I would like to show you the issue about no separation of constructing and using it and then I'll give you some approaches to overcome this issue.

| Note: you can find the below demonstrated code here
Take a Look the Following Simple ApplicationUsed tools and technologies: Eclipse (Mars), JDK 1.8

I had an App which uses Controller. Controller uses Service (an interface). Finally, Service has one concrete class is DefaultService.
//package vn.nvanhuong.system.separationconstructing; public class App { public static void main(String[] args) { Controller controller = new Controller(); controller.doAction(); } } public class Controller { private Service service; public void doAction(){ System.out.println("doAction in Controller"); getService().execute(); } public Service getServi…

The Evolution of Team Collaboration

In my point of view, if a team has a good collaboration, team members will achieve the following: To be more effectiveTo make work more enjoyableI have been working for a company for nearly four years as an software developer. Working on various projects from maintaining existing systems to developing a substantial product resulted in me moving to new teams three times. Actually, my most stable team lasted only around three years. 
Every time I've moved to a new team, I have a chance to work with new members and a new team culture again. Indeed, I realize that there is a process of developing the team collaboration which gets better time by time. I think it is an evolution! Phase 1: Poorly collaborateFor example, that is when the team members have the following issues: Only work on his/her area of expertiseDon't communicate to othersBe not confident to take on new challagesDon't listen to other members.
Subsequently, the team has some Failed Sprints and the knowledge gap betwe…