Antoine Sauvinet — Technology Executive & Entrepreneur
FR | EN
Blog Resume Contact

[EnhanceYourCode] : the Builder Pattern, Part2

Hello, In the previous article, we explored the theory of the builder pattern. Let’s see a more concrete example : Let’s assuming that we are building a Role Playing Game core model. Here are the basic rules: A player can be a Hero : a Warrior, a Wizard, or a Thief (we keep it simple) Every Hero has 4 main characteristics: Health, Strength, Spirit, and Speed, that are counted in points. Heroes have a Level, and starting characteristics are based on this level (Health starts at Level * 10, Strength and Spirit start at Level * 5, and Speed starts at Level * 3) Warrior has a (+2 Strength, -2 Spirit) Modificator, Wizard has (+2 Spirit, -2 Strength) Modificator Player can improve 2 Characteristics of 1 points each or 1 characteristic of 2 points, in order to cutomize his Hero. A naive implementation of the Hero class would be : ...

September 16, 2015 · 7 min · 1343 words · oinant

[EnhanceYourCode] : the Builder Pattern

Hello, In this article, I’d like to present you the Builder pattern and how I use it in my C# code. The Builder Pattern is a Creational design pattern, like the Factory Method Pattern I already covered un this previous article. Its main focus is to provide a light DSL to build objects by settings startup properties, by seperating the process of constructing an object from the object itself. Basically, the idea is to create a class with mutable fields, that will be initialized with dedicated methods, and a final method that create the object itself from thoses values. Here is an abstract example : ...

September 9, 2015 · 3 min · 621 words · oinant

[Node.js] Build a clean process manager

In this article, I’ll demonstrate how to buid a simple and maintainable process manager for Node.js, leveraging its Event Loop. The main idea is have a core processor that will be able to run a serie of tasks, in a synchronous way. As you may know, Javascript is by essence an asynchronous language. Let take simple example : 1 2 3 4 5 6 7 8 function CrawlingAWebPageAndGetLinks(){ // do the stuff the method pretend; } (function program(){ var result = CrawlingAWebPageAndGetLinks(); console.log(result); })(); As the execution flow is asynchroneous, the result variable will not be valued before the crawling method ends, and the usage of the variable will occurs before its valuation The standard solution in javascript to handle this issue is to use a callback method : ...

August 30, 2015 · 4 min · 840 words · oinant

[EnhanceYourCode] : the Factory Method Pattern

The Factory Method pattern is one of the most useful creational design patterns. It allows us to delegate the creation of an object to a dedicated class, improving testability and respecting the Single Responsibility Principle.

July 22, 2015 · 6 min · 1123 words · oinant