Skip to content

Instantly share code, notes, and snippets.

View erichonorez's full-sized avatar

Eric Honorez erichonorez

  • Buy Way Services
  • Brussels
View GitHub Profile
@erichonorez
erichonorez / rest_api.js
Created February 10, 2013 19:09
A simple REST API with Node.js and Express
/**
* TaskRepository class deals with task persistence
*/
function TaskRepository() {
this.tasks = [];
this.nextId = 1;
}
/**
* Find a task by id
* Param: id of the task to find

Microservice architecture is not a software development approach

Microservices are often presented in contrast of monolithic applications which are frequently associated to a Big Ball of Mud. If your application is a BBoM don't expect microservices will help. They are not a turnkey solution to good design and modularity.

I think that it is really important to understand that microservices are just an architecture style. It's nothing more than Service Oriented Architecture with a couple of opiniated patterns, principles and practices. These tools give guidelines in order to create distributed systems. The main goal of this kind of architecture is to enable different teams to work autonomously on different part of a system and thus improve the overall productivity. When well applied microservices are an investment that will allow you to quickly evolve and make choices independently from other teams.

Microservices won't help you to improve the quality of your code. This architecture style is not a solution

A Gentle Introduction to Hexagonal Architecture

Background

Frameworks are great. They helps us to gain productivity improve quality and unify practices. Because of our needs evolve the framework we choose today could not be the one we will need tomorrow.

Moving from a framework to another may involve a complete refactoring of the application if its architecture is not flexible enough. This is expensive, risky and often hard to justify to the business.

Application's business behaviors should not be impacted by moving from one framework to another.

Hexagonal Architecture

@erichonorez
erichonorez / future_option.scala
Created December 7, 2016 20:18
Future & Option composition in scala
// Start writing your ScalaFiddle code here
import scala.util.{Success, Failure}
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
import scalaz._
import Scalaz._
import scalaz.OptionT._
type User = String
type UserDetail = String
@erichonorez
erichonorez / state.scala
Created December 13, 2016 20:39
State Monad
import scalaz._
import Scalaz._
sealed trait Transaction {
def value: BigDecimal
def apply(amount: BigDecimal): BigDecimal
}
case class Credit(value: BigDecimal) extends Transaction {
def apply(amount: BigDecimal): BigDecimal = {
@erichonorez
erichonorez / scalaz_validation.scala
Last active December 13, 2016 21:21
Validation with scalaz
// Start writing your ScalaFiddle code here
import scalaz._
import Scalaz._
case class LoanApplication(
val firstName: String,
val lastName: String,
val nationalRegister: String,
val emailAddress: Option[String]
package com.example.demo;
import lombok.Value;
/**
* This example implements event sourcing using with versioning. It uses
*
* Each version has its own event interface (e.g. {@link EventV1} and {@link EventV2}) that extends the {@link Event}.
*
* In order to apply {@link Event} on a {@link State} the visitor pattern is used. Each version also define its own visitor interface (e.g. {@link VisitorV1} and {@link VisitorV2}). All visitors are aggregated with the {@link Visitor} interface.
package com.example.demo;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;
import lombok.AllArgsConstructor;
import lombok.Value;
package com.example.demo;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import lombok.Value;
import static io.vavr.API.$;
import static io.vavr.API.Case;
@erichonorez
erichonorez / IssueTracker.hs
Created December 10, 2018 06:02
Event sourcing in haskell
{-# LANGUAGE OverloadedStrings #-}
module IssueTracker where
newtype RepositoryId = RepositoryId String deriving (Eq, Show)
newtype OccuredOn = OccuredOn String deriving (Eq, Show)
newtype UserId = UserId String deriving (Eq, Show)
newtype Label = Label String deriving (Eq, Show)
newtype DateTime = DateTime String deriving (Eq, Show)
newtype MilestoneId = MilestoneId String deriving (Eq, Show)