December 30, 2016

JUnit 5! What's new?

JUnit 5 is finally out. I will take this opportunity, to introduce some of its new features. I will point out only the features that I have found most interesting.

Annotations

The JUnit Team has changed a lot of the annotation names so that it is clearer how and when they should be used. The underlying behaviour is still the same. Methods which are annotated with either @BeforeAll or @AfterAll must be static because each test creates a new instance, and, therefore, it is unclear on which instance they have to be invoked. [1]

December 20, 2016

iOS Deep Linking - Common Challenges and Their Best Attempt to Solve Them


Introduction

"Deep links" are a powerful mechanism for making web/mobile app content more easily accessible. By automatically navigating to the desired page/screen we are able to improve the user experience dramatically.
Instead of requiring users to click through several pages – starting from the "home screen" – we can point them to a specific location within our app. Usually, a deep link is contained in, for example a push notification, an email, a Facebook advertisement, and so on. Furthermore, we can drive users back to our app from the mobile website with Smart App Banners in the Safari browser. See below for two real world examples. In the next few sections, we will show you what to consider when implementing such functionality on iOS.

December 19, 2016

Performance Testing with Gatling, Part 2

This is the second part of a two-part series covering theories on performance testing. This part showcases how to set up Gatling in IntelliJ. It provides some practical examples using Gatling, and explains how to get a graphical report for your execution results.

Sample Application

You can clone the sample application here: https://github.com/willhaben/gatling_part2

December 13, 2016

Avoiding the Implicit

TL;DR: You have a mixed Objective-C/Swift project? Avoid runtime crashes by adding nullability annotations to your Objective-C headers. Integrate this cool script to find missing annotations. Also activate Treat Warnings as Errors.
We love the dynamic freedom of Objective-C, and we also love the static safety of Swift. We know that Swift is the future, but we cannot migrate everything at once, so we live in a mixed world, Objective-C and Swift tangled together via The Bridge.
The Bridge is a wondrous thing, but danger lurks in the dark. In this article, I want to help you sharpen your tools to defend yourself from a special kind of beast: Implicitly Unwrapped Optionals (IUOs) that crawl over from Objective-C land into Swift.

November 22, 2016

Visual Search applied – the “Fashion-Cam”

Artificial intelligence features are slowly becoming industry standards in modern products and services in every niche. Now, they are being integrated into the willhaben Fashion-Cam. The visual search project, originating from the Styria Innovation Incubator, provides a cutting edge system to add machine learning methods to existing search agent features. This empowers users to search for classified ads using photos of interesting products using either a photo taken by the user, or one from an existing ad.

November 07, 2016

Mutation Testing – Integrating into a large (legacy) application

This blog demonstrates the concept of mutation testing on real-world examples. It tries to show how it can be integrated into an existing large (legacy) code base and how it impacts the build time. Based on this information, I want to give you some ideas about how mutation testing can be introduced in your applications.

October 12, 2016

Performance at its (CPU-) Core

Who should read this?

This article will be interesting for you if you:
    • Are trying to decide which hardware to buy;
    • Are designing a service that is supposed to run on a specific hardware specification;
    • Are an operator like me; or,
    • Generally like to fiddle around with hardware and tune system performance.

    October 04, 2016

    Launching a new product – from zero to native couponing

    Recently, we successfully launched native couponing in our Android and iOS Apps. Providing coupons with discounts in various areas provides benefits to the approximately 1 million people who use our mobile services on a regular basis. Our users collected more than 15,000 coupons in just the first couple of weeks after launch.

    Launching a completely new product is always a challenge, especially if you have a lot of stakeholders – product managers, digital advertisers, sales people, developers, quality assurance specialists, etc. just to name a few. All of them are involved in building great products for our users.

    From the viewpoint of a technical project lead, it is challenging to meet all the functional and non-functional requirements. This blog post shows how we bootstrapped a new product from the technical side, from zero to getting it into production; which technology we used; which architecture fits our requirements; how we embedded it in the existing infrastructure; and, most importantly, what to avoid. This article will cover these topics at a high level and will not provide any implementation details.

    September 28, 2016

    Parallel Streams

    The Streams API that came with Java 8 enabled functional programming by taking advantage of the new lambda functionality and the method references. One of the most popular features of streams is that they support lazy evaluation. Another very popular feature of streams is that they are capable of processing results concurrently using multiple threads. In this article, we will examine the main points to consider when using a parallel stream.

    Creating a parallel stream is really simple; you just have to designate that your stream is parallel and the operations are done in parallel automatically for you. There is no need to write any threading code to make it happen. There are 2 ways to create a parallel stream: you can either create it from an existing stream, by calling the parallel() method, or use an extension method that has been added to the Collection interface, as below:
     Stream<String> stream = Stream.of("cat", "dog");  
     Stream<String> parallelStream = stream.parallel();  
       
     Stream<String> parallelStream2 = Arrays.asList("cat", "dog").parallelStream();  
    

    September 27, 2016

    Optionals in Java 8 and How to Use Them

    Since the release of Java 8, NullPointerExceptions shouldn't be common anymore. Before Java 8, your code was probably full of "if statements" to check if a variable was null. Still, it was impossible to catch every NullPointerException out there. With Java 8, Oracle attempted to solve this issue. They didn’t invent the holy grail, but they did make our lives as developers much easier by helping prevent code smells and those nasty Exceptions. Now, if you start a new project, you should definitely use Java 8 to avoid NullPointerExceptions.

    So what exactly did Oracle do to help us in our misery? They introduced Optionals. [1]

    You may have heard of Optionals already a few times, but you maybe dont know exactly know how to use them in the right way. If you use them in the wrong way, it is like you wouldnt use Optionals at all. So let's take a look how Optionals could be used.


    Java 8 Date and Time API [Quick Introduction]

    Along with new language features like lambda expressions and streams, Java 8 has also introduced a new concept to deal with dates and times. Working with dates and times prior to Java 8 was a little tricky and cumbersome, which led to the popularization of third-party time libraries like Joda-Time. Even for those starting to learn Java with version 8, it is still important to be able to understand the code written the old way. In this article, we will examine the core differences between the old and new way.

    First of all, in order to use the new classes, import the java.time package like this:
     import java.time.*;  
    

    August 21, 2016

    iOS: Creating a Custom UIViewController Transition Animation – a Step-By-Step Guide

    First of all - what is this 'Transition animation', you might ask? Well, no rocket science here - transition animations provide visual feedback about changes to your app’s interface. UIKit provides a set of standard transition styles to use when presenting view controllers, and you can supplement the standard transitions with custom transitions of your own.You may have seen a lot of transition animations that look really nice and neat but you might not have any idea of how to create one. Some of them look really complicated and some really simple, but in the end you just don't know where to start.

    That's why I am going to introduce you to custom transitions. In this step-by-step guide, we are going to create a regular custom transition animations and, in doing so, wash away any fears you might have had about them.
    So let's get started!

    July 04, 2016

    The WWWW Guide to Refactoring

    If you are working on an ever-evolving codebase, refactorings are something you're sure familiar with. Martin Fowler’s Refactoring book is a must-read for any developer. Lets start with his definition of refactoring:
    Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code, yet improves its internal structure.” [1]
    The book describes the process of refactoring and spends most of the time explaining how to do the various refactorings. In this post I will talk about the essential wwww questions:


    WHY should we refactor?
    WHEN should we refactor?
    WHO is involved in a refactoring?
    WHAT should be refactored?

    June 27, 2016

    Sorting objects - working with "Java Comparator"

    Today I want to show you how to sort objects by one or more properties. There are a lot of possibilities how to do that.
    There are two interfaces in Java which help you to sort a list. There is the Comparator interface and the Comparable interface. So how do you decide which one to use?

    API interface definition Comparable<T>:
    "This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering, and the class's compareTo method is referred to as its natural comparison method."  [1]

    Simply put, if you implement the Comparable interface in a class, the class instance is able to compare itself to another object. So you can just use Collections.sort(List<T> list); and you will get a sorted list.

    June 22, 2016

    Performance Testing with Gatling, Part 1

    This is the first part of a two-part series covering the theory on performance
    testing. The next part will showcase a practical example using Gatling, an “open-source load
    testing framework based on Scala, Akka and Netty”.

    Introduction

    Testing system performance can be done on multiple levels. Last time, we covered micro
    benchmarking with JMH. Whereas micro benchmarking deals with optimization of code and algorithms, testing system performance ensures that an entire system meets the required metrics such as throughput and response times.

    March 25, 2016

    Event Sourcing at willhaben

    This is the start of a series of blog posts about the introduction of Event Sourcing and Command Query Responsibility Segregation (CQRS) in one of our internal products. The first blog post gives a short introduction to these topics and talks about the problem domain and the current status of development. Further posts will talk about the concepts in detail and our lessons learned. So stay tuned for more.


    The problem domain

    At willhaben we currently deal with around 120.000 new ads and around 200.000 ad changes per day. For this data we need to make sure that the data adheres to our quality standards and to our terms & conditions, e.g. the ad must be placed in the right category. Also we want our users to be fair to others and not reinsert an ad in order to be pushed to the top of the search result.

    For this reason we've developed a system where the people in the quality assurance department can define rules which implement the current quality requirements. The rules can be created, changed and deleted at runtime, making the system very flexible for rule editors because no developers or deployments are needed for changing business rules.



    March 22, 2016

    Implementing Leader Election and automatic fail over

    Leader election and automatic fail over are two common tasks in every distributed environment. There are various reasons why multiple instances of the same software are running at the same time, for example because of load balancing, hot standby or dedicated instances for different tasks (same software but other configuration, etc.). Depending on your architecture, different aspects of these are more important than others. Furthermore, it is easier to develop services that have one master and one or more slaves than developing service set-ups in which every service is equal.

    One common task would be having multiple services running for load balancing but only one that executes batch jobs like data base clean up jobs. This can be done in different ways, but one smart way would be to have the same configuration for all service instances and let the services decide at runtime which one executes the batch job (typically the master slave: the master executes the batch jobs and the slaves do not execute any batch jobs at all).

    March 21, 2016

    A taste of reactive components

    The easiest way I can imagine to build a web application is just putting together some HTML and Javascript until I get more or less what I want. But usually, as the project grows, I end up with some unmaintainable mess. Why is that? Lets take a look at some code:




    January 22, 2016

    Micro Benchmarking with JMH


    Developing software and algorithms normally becomes more difficult with the amount of data that needs to be handled. Processing thousands of data records on modern hardware is no problem at all. However, when millions or hundreds of millions of records need to be processed, it can be quite difficult to meet the expected runtime performance. A batch job that should be executed every hour, for example, has to finish within this exact time frame. So how can we efficiently improve runtime, even in large-data contexts? Vertical scaling has its limits and horizontal scaling can take more effort than optimizing the batch job performance itself. Alternatively, let’s look at micro benchmarking as a means to optimize certain parts of a programm.


    Let’s assume we have two sorted lists with integers and we want all integers that are in the first list but not in the second one. According to set theory we want A \ B (blue area in the figure below).