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