patterns

Alpakka (Akka Streams) vs Apache Camel: who wins?

Most software engineers have to work with enterprise integrations, and, since we are all lazy, we love to use stuff that provide things out-of-the-box. Before I start, I have to say: I already have worked with both Camel and Alpakka, so, I'll try to make the fairest comparison I can. Apache Camel is a "lightweight ESB" and has been around for sometime now. It is widely adopted and battle-tested on production at many companies, like Cisco, Netflix and JPMorgan. On the other hand, the Alpakka project is relatively…

Keep reading

The basic you should know before building your REST api

There is no recipe to build a REST api, but, there are a lot of good practices that could be followed, so, I gathered the most used and well accepted practices that you should know before building yours. Index Most commonly used HTTP methods GET POST PUT PATCH DELETE Most commonly used HTTP status Don't use verbs in the resource uri Always use JSON as the content-type Envelop your response Make client-side errors well explained in the response Support versioning, but avoid to use it Support async and callback operations…

Keep reading

Why you should avoid conditional statements

Developers tend to use a lot of conditional statements in their code. Of course, each flow has one specific path, its own specific validations, etc. It is very natural that your code has a lot of decisions to be made at runtime, but, mostly, when you use a lot of conditional statements in specific area of your code, probably you are not using it right. Conditional statements should be used for small decisions, not big decisions, not for choosing one path of five others. (It really hurts to see chained…

Keep reading

8 design patterns that every developer should know

As a developer, you are constantly resolving problems. Many of these problems probably were already solved by other developers, so, why do we need to solve them again? You have a problem, specifically a common problem, so, you try to find out if anyone already did the job solving, before you try to resolve it, right? You probably don't want to reinvent the wheel, do ya? Design patterns are there for these situations. Unfortunately there are a lot of developers who still refuse to use a few patterns, mostly because…

Keep reading

CDI, Polymorphism and The Factory Pattern

One of the most useful things about object oriented programming is polymorphism. In fact, it makes our software have different behaviors without the need to explicit it in the code. For instance, you are writing a code to make a credit card transaction. If it is a VISA transaction, you should execute one specific action, if it is a MASTERCARD transaction, you should execute another specific action, so, the first thing you think about doing is: public void pay(Transaction transaction) throws UnsupportedCardNetworkException { if("visa".equals(transaction.getType())){ //pay with…

Keep reading