As a quick review of template method and chain of responsibility patterns we can define a template of the chain (no to have a broken chain) with an abstract class:

abstract class MiddlewareBase {
static MiddlewareBase of(MiddlewareBase... middlewares) {
for (int i = 0; i < middlewares.length - 1; i++) {
middlewares[i].setNext(middlewares[i + 1]);
return middlewares[0];
private MiddlewareBase next;public void setNext(MiddlewareBase next) { = next;
public final void check(Request request) {
if (next != null) {
abstract void checkInternal(Request request);

Until now this is good and seems perfect, now to…

While I was working on fixing a bug today, I came across with a method containing a conditional check to execute some updates on some business object. It was like:

and because this resulted to a bug I had to understand and imagine the intention of this code’s author when he/she wrote it.

Okay, then I spent some time to understand what he wanted. And because I like refactoring I thought of how to make this check make more sense, the refactoring for this is almost direct and clear, simply by presenting a name for the sub-conditions like:

A friend asked me to work on an EJB and EJB client project in an independent separated deployment package for each.

I get used to use Netbeans to do that along time ago, but I decided to do it with maven. Looking for that I found that Apache provided plugins of EAR and EJB application for maven: for deploying artifacts as a Java EE Enterprise Archive (EAR) which generates Java Enterprise JavaBean (EJB) file as well as the associated client jar.
That was almost perfect though the documentation was not clear enough. …

Yes, inheritance means adding or changing the behavior of a class by a sub class
the traditional way of doing inheritance is by extending a class adding new methods.
Let us take an example from Java world

Super class

extending this class to add a new behavior can be done directly and easily:

Factory pattern is one of the most used design patterns in Java. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object.

In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.

Let us take an example of loyalty Tier represents the level of member

To get instances of Tier based on some criteria without specifying the concrete implementation we can use the Factory pattern as following:

Muhammad Durrah

SoftwareDeveloper extends SoftwareEngineer{}

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store