Home » Author Archives: Marco Castigliego

Author Archives: Marco Castigliego

Strategy Pattern in Java 8

java-logo

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

software-development-2-logo

                        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

java-logo

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

git-logo

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

java-logo

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

software-development-2-logo

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

software-development-2-logo

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

junit-logo

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

mockito-logo

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!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.