The Composite design pattern has the intention to represent part-whole as your friends on social media or a tower, as in the picture below.
Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly .
Using a composite structure, we can apply the same operations over both composites and individual objects. In other words, in most cases, we can ignore the differences between compositions of objects and individual objects.
The diagrams below show how to identify this pattern and the participants.
When do you need to connect things, one of the options is to build a bridge, and this pattern is an example of it in code time upfront of integrations.
Excerpt from GOF book,
When an abstraction can have one of several possible implementations, the usual way to accommodate them is to use inheritance. An abstract class defines the interface to the abstraction, and concrete subclasses implement it in different ways. But this approach isn’t always flexible enough. …
Working with a dev environment is kind of different from prod, and managing the changes should be too. To achieve the changes Liquibase is an option rather than Hibernate create-drop strategy.
To maintain all DB schema changes into one place, Liquibase has these reasons.
For this tutorial, the focus will be on item 1.
Write code is great, but sometimes is better generate code than type them. For this article I’ll present some options, such as Lombok and MapStruct.
As I said before, sometimes writing a repeated piece of code is not a good idea, since this is a DRY (Don’t Repeat Yourself).
After the arrival of the Java Annotations changed the game.
Lombok uses the Java Annotations feature to…
Working with Lists is a common task in Java, but this task should be done carefully whether the unmodifiable or immutable is required.
This article covers the change inside the elements of the List in order to avoid problems, for instance: Where is the element nth? Why did the element have one value and now has another value?
Retain the data as is, and don’t allow any element change, if required or a man in the middle.
The term unmodifiable means that the structure of the List itself cannot be altered.
If the elements in the
List are mutable (which…
It was a kind 😆 of weird, handle all the Kubernetes (k8s) commands on my local environment and then I decided to install the k8s dashboard.
Solve the problem to see a GUI instead of CLI. Although help when you’re starting on k8s and/or won’t have in mind all k8s commands, there are so many, check it out.
Install the dashboard using the following steps:
helm install dashboard kubernetes-dashboard/kubernetes-dashboard -n kubernetes-dashboard --create-namespace
After for the umpteenth time type the command port-forward I noticed that I had to use Ingress 😜 and avoid the famous DRY (Don’t Repeat Yourself).
Disclaimer → Is not wrong use port-forward command, but if you can don’t remember it, looks great.
Assumptions → You’re familiar with docker and has installed the softwares below.
For this tutorial I’m using the following softwares
In terms of deploy, I’m using an application built with Quarkus, with 2 endpoints, /resteasy-jackson/quarks and /hello-resteasy. The image is available on my Docker hub.
This is an overview of those piece together…
Let’s play on my brand new video game? I can’t because my old television doesn’t support the video game interface. May you already face this situation someday.
Excerpt from GOF book
How can existing and unrelated classes work in an application that expects classes with a different and incompatible interface? 
Excerpt from GOF book,
you want to use an existing class, and its interface does not match the one you need.
you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don’t necessarily have compatible interfaces.
(object adapter only) you need…
Disclaimer ⚠️. Even though this pattern belongs to the code smell section in Java, worth knows it and recognize and know what is your purpose.
Below we can see the prototypes of Stormtrooper since for me they’re always equals.
Use the Prototype Pattern when a client needs to create a set of objects that are alike or differ from each other only in terms of their state and creating an instance of a such object (e.g., using the “new” keyword) is either expensive or complicated.
Excerpt from GOF book,
Use the Prototype pattern when a system should be independent of…
This pattern works together with the factory method, my last article before it, and creates a family of objects. Based on that, let’s see your structure and how to implement it.
To write this article I used the Gang Of Four, Head First Design Patterns, and Wikipedia. All the links are available in the References section.
Consider a user interface toolkit that supports multiple look-and-feel standards, such as Motif and Presentation Manager. Different look-and-feels define different appearances and behaviors for user interface “widgets” like scroll bars, windows, and buttons. To be portable across look-and-feel standards, an application should not hard-code…
Hi there 👋 , I’m Luiz Gustavo I’m a Brazilian and don’t play soccer very well, then I became a software developer