Home » Author Archives: Marco Castigliego

Author Archives: Marco Castigliego

Strategy Pattern in Java 8

These are two examples on how to implement a Strategy pattern design using Java 8 functional style together with Cyclops pattern matching and Hamcrest libraries. PrintDependingOnInput method is a strategy that will System.println some message based on the log passed. AddPrefix is another strategy that will add a prefix to a message based on the message content. package com.marco.patternmatching; import ...

Read More »

10 team building tips

                        1. Good Morning When you enter in the office, before sitting on your desk, smile and say good morning to the team. Yes, E V E R Y day. 2. Listen when someone is talking to you. When a team member is talking to you, look him in ...

Read More »

Friday-Benchmarking Functional Java

Lets image our product owner goes crazy one day and ask to you to do the following : From a set of Strings as follows : "marco_8", "john_33", "marco_1", "john_33", "thomas_5", "john_33", "marco_4", .... give me a comma separated String with only the marco's numbers and numbers need to be in order. Example of expected result : "1,4,8"     ...

Read More »

Migrate your project from SVN to Git Stash in few steps

Step by step guide on how to migrate your SVN repository with all its history to the Stash, the Atlassian git manager.                   Only once : add the ssh key open a terminal create the authors.txt file in ~/Documents/ git config svn.authorsfile ~/Documents/authors.txt authors.txt format : username = Name LastName <email> example ...

Read More »

Java 8 : Functional VS Traditional

The business logic is the same : Given a String expression composed of visits / time like : “1/24h,1..3/3h,5/*” Then the result should be the following list of Strings: “1/24h”, “1/3h”,”2/3h”,”3/3h”, “5/1h”,”5/2h”,”5/3h”,”5/4h”,”5/5h”,until ,”24/1h” So, 2 things need to be solved, the dots and the stars for the visits and for the time. I will use Java 8 , but  I’ll ...

Read More »

Why you should not work extra hours

There are pros and cons in working extra hours or over time regularly, here is an attempt to list them all. Some are well known, some are taken from my experience, if you know other reasons just comment and I’ll include them in the list.                 CONS: You are going to introduce bugs  ...

Read More »

Funny Bugs types

Incompatible classes when you try to deserialize files generated with old code… Wrong URL setting when you put a wrong rest url in your property file and you receive no messages… Too verbose xml messages when SLAs are not met because your XML messages are too big wasting time in serialization and deserialization… Production with no tests when you go ...

Read More »

Access private fields in unit tests

First of all, let me say out louder, you need to design your code to be testable, so you test your private fields through your public methods. But, (“buts” are the reasons why humans are still programming instead of the computer itself, so be happy here) sometimes you want to and should alter some private fields in order to test ...

Read More »

Testing Spring components with Mockito

Be able to unit test your spring components without the need of loading the full spring-context with its ad-hoc test configurations it is ,in my opinion, a great advantage because it’s clean, easy to maintain, faster to write, smooth to alter. A way to achieve this goal is to use Mockito and tell him to replace the @Autowired components in ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns