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. …
Ready to not use your local environment? This is the idea behind the GitPod “Spin up fresh, automated dev environments, for each task, in the cloud, in seconds.”
You can play into a free tier as I’m doing, that means 50 hours monthly.
Click on the Try Now button if you’re a new user and the arrow indicates.
By default when I need to write a code to communicate with Repository I thought to use CrudRepository, but the JpaRepository also is an option, so should I review my bias?
Explain the difference between the interfaces CrudRepository and JpaRepository.
To explain the difference let’s see the diagrams of each one.
From my point of view, the CrudRepository is the most used in tutorials/articles and does your work well.
To prevent working with production resources in a local/dev environment the use of profiles is highly important, in this article let’s see how Quarkus helps us to achieve the environment configuration.
Since Java 1.5 when the Generics was introduced, the Java developer life changed a lot, and changed in a good way.
In this article will handle Covariance(? extends T) and Contravariance(? super T) and will be splitted into definition, example, and conclusion.
Using the covariance is allowed to use any subtype of FirstClass, such as Suite and Superior instances.
List<? extends T>
// or in the example
List<? extends FirstClass>
Use elements defined to use in the declaration of its supertypes.
List<? super T>
// or in the example
List<? super Gourmet>
All super classes based…
A long time ago in a city far, far away…. 👾 well in fact was in Araraquara, Brazil 🇧🇷. Due to a connection speed we faced some problems to make the application start up properly (timeout), then a team mate, Eduardo had an idea to build a proxy to solve the problem, from this day forward I would know of the existence of this pattern.
Based on the GOF book “Provide a surrogate or placeholder for another object to control access to it.”.
Sounds abstract, doesn’t it? 😟
Let’s see the definition by Head First book “A remote proxy acts…
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…