Creating, Using & Building a DSL

, Software Pundits
This post was originally published on this site

Apium Hub

The main idea behind this article about building a DSL is to play and experiment with some design patterns on a surface level.

We’ll have a character with a position, and we’ll move it in four directions thanks to the commands grouped in a DSL. These commands can be undone and move the character back to a previous position.

Building a DSL: Character

The first thing that we’ll create is our Character domain class, where we’ll put all the logic related to the character’s movement. It will be able to move up, down and sideways.

Memento

Memento is a pattern design with the goal of stacking an object’s state at a given time.

We’ll create our Memento class to stack each of our Character’s previous states.

Originator

Originator creates a Memento object containing a photography of its internal state.

We’ll create an Originator interface and implement it on our Character

To read the full article click on the 'post' link at the top.