development

Tips and Tricks to Master development

The builder pattern

Development Jun 22, 2016

Builders are a powerful tool to avoid telescoping constructors.


The builder software design pattern is an object creation one. It’s a great building block for classes with optional fields. It provides a maintainable and readable way to instantiate immutable classes with more than 3 or 4 fields. It greatly reduces the time developers needs to understand how to instantiate the class properly. You have surely faced one day or another a code similar to the one below. public class Person { private final String firstname; private final String lastname; private final String address; private final String zipCode; public Person(final String firstname, final String lastname) { this(firstname, lastname, ""); } public Person(final String firstname, final String lastname, final String address) { this(firstname, lastname, address, ""); } public Person(final String firstname, final String lastname, final String address, final String zipCode) { this.

Angular2: simple Drag and Drop

Angular2: simple Drag and Drop

Development May 27, 2016

Creating simples drag and drop zones using Angular2.


We are using drag and drop extensively for creating virtual users in OctoPerf. As I plan to migrate to Angular2, today I wanted to check how to handle drag and drop in the future of AngularJS. I started from the W3Schools plain HTML / JS example and created the following component: import { Component } from 'angular2/core'; @Component({ selector: 'dnd', directives: [], styles: [` .container{ border: 1px solid red; width: 336px; height: 69px; } `], template: ` <div id="div1" class="container" (drop)="drop($event)" (dragover)="allowDrop($event)"> <img id="drag1" src="http://www.

Why objects must be Immutable

Why objects must be Immutable

Development Apr 7, 2016

Immutable objects are objects whose state cannot change after construction.


Immutable objects have multiple advantages over mutable objects which makes them the perfect building block to create software. You may already have many questions about the subject like: Why should I use immutable over mutable objects? How can I design software where no single object can be modified? You’ll see in this article what an immutable object is, the advantages to use them every time you can and how they can speed up your software developments.

Angular2: filtering ngFor using pipes

Angular2: filtering ngFor using pipes

Development Apr 5, 2016

How to filter the content of a table using pipes in Angular2.


Angular2 / Bootstrap4 table I’m still working on a Stripe administration console for OctoPerf, a SaaS performance testing tool. Stripe lets us manage our customers and their subscriptions. I have a table that lists all of our customers (Customers.html): <table class="table table-striped"> <thead class="thead-default"> <tr> <th>#</th> <th>Id</th> <th>Email</th> </tr> </thead> <tbody> <tr *ngFor="#customer of customers; #i = index"> <th scope="row">{{i}}</th> <td>{{customer.id}}</td> <td>{{customer.email}}</td> </tr> </tbody> </table> It’s an Angular2 application build using this excellent starter with BootStrap 4.

Angular2: hard time unit testing Http requests

Angular2: hard time unit testing Http requests

Development Apr 5, 2016

Mocking the Angular2 Http service for unit tests using karma/jasmine.


To follow up on my article about unit TypeScript generics in Angular2, I would like to unit test my Stripe client. It involves mocking the Angular2 Http service, and it’s far more complicated than unit testing the Router service. I first tried to inject a mock of the Http service and return custom Observable responses but this led to strange errors and cumbersome code. I quickly switched to the recommended way, using MockBackend.

Angular2: using TypeScript generics

Angular2: using TypeScript generics

Development Apr 4, 2016

A sample usage for TypeScript generics when using Angular2 Http service.


This post is an example of TypeScript generics usage, when writing an Angular2 application. I’m working on a Stripe administration console. Stripe is a payment / subscription SaaS service that we use at OctoPerf. I need to create pages that lists all our customers and plans. But Stripe returns paginated lists, and we need to do successive calls to their API to get the complete data. This mechanism is the same for both customers and plans lists.

Angular2: method callback type in TypeScript

Angular2: method callback type in TypeScript

Development Apr 3, 2016

How to set the type for a method callback in TypeScript when using Angular2 Http service.


It’s my third post about Angular2 and TypeScript as I’m creating an admin console for OctoPerf load testing platform. Intro This article explains how to set a type for callbacks. If, like me, you are used to AngularJS you may often use callbacks for asynchronous calls, typically for HTTP requests. I wrote a StripeClient service that can return the list of my Customers. In pure JavaScript it would be fairly simple as you don’t need to give a type to your callback.

Unit testing in Angular2

Unit testing in Angular2

Development Mar 31, 2016

Unit testing a component that uses the Router, in Angular2.


Unit tests in Angular2 with Karma To follow up on my first article about Angular2 I want to unit test our Login component: import {Component} from 'angular2/core'; import {AuthenticationService} from '../services/authentication'; import {Router} from 'angular2/router'; @Component({ selector: 'login', providers: [ ], directives: [ ], pipes: [ ], styles: [ require('./login.css') ], template: require('./login.html') }) export class Login { private credentials: string = ''; constructor(private authService: AuthenticationService, private router: Router) { } onSignIn(){ this.

Creating a singleton Service in Angular2

Creating a singleton Service in Angular2

Development Mar 29, 2016

From AngularJS to Angular2, the hierarchical dependency injection may be tricky.


Motivation, building a licencing application I already use AngularJS for the frontend of OctoPerf, a load testing solution. I will need to migrate my application from AngularJS to Angular2 in a few months. To get ready for it I created a licenses management application. I started from the excellent angular2-webpack-starter. The sample AuthenticationService I quickly needed to create a singleton service and found out that it’s not as straightforward as in AngularJS.

Immutable Spring Service with Lombok

Immutable Spring Service with Lombok

Development Mar 24, 2016

Learn how to create constructor injected spring services with lombok.


Project Lombok is an amazing Java library which makes it possible to write very concise code. It’s an incredibly powerful library which uses an annotation processor to generate code behind the scene. Why use lombok Let me show you a very simple example: @Value public class Person { String firstname; String lastname; } Is equivalent to the vanilla Java example: @Value public final class Person { private final String firstname; private final String lastname; public Person(final String firstname, final String lastname) { this.