Skip to main content

Workflows with the visitor pattern

· 11 min read

Workflows

As a software developer I work, most of the times, on LOB applications that support some kind of process or workflow for a specific company. That means that there are some entities, such as customers, orders or support tickets, and that they evolve during the lifecycle of the application. For example we could have a CRM with a lead entity that evolves into a customer or we could track the state of a ticket: open -> analysis -> work -> deploy.

Parsing polynomials with F# and FParsec

· 9 min read

Parsing polynomials with F# and FParsec

Parsing a polynomial expression is a simple but interesting example of parsing. We need to handle operator precedence and associativity, for example * has a higher precedence than + and the exponentiation is right associative x^y^z=x^(y^z) while subtraction is left associative x-y-z=(x-y)-z. Moreover a straighforward definition of the grammar is left recursive and a recursive descent parser does not allow to parse such grammar. We need to arrange our grammar in order to avoid the left recursion.

Parsing polynomials with the Pratt algorithm

· 4 min read

polynomials-pratt-algorithm

Using a Pratt parser I aim to parse expressions like this x^2+y^2-1, x=1, y=1 and xy, x=2, y=3. Parsing mathematical expressions it's not hard but it already contains some interesting behaviour such as associativity between operators x+y*z is equal to x+(y*z) and not (x+y)*z. For no particular reason I decided to put the variable assignments after the polynomial. The expression x^2+y^2-1, x=1, y=1 is to be interpreted as you would with this pseudo code

Antlr4 polynomial grammar - 2020 update

· 5 min read

Antlr4

A few years back I was playing with Antlr to build a polynomial evaluator. The result was working but not very sofisticated o particularly good, just a minimal working example. In these days of quarantine in Italy, I decided to get back a that project and try to make something better. The final result can be found at this repo.

Railway oriented programming with C#

· 5 min read

2021-09-29 I added an example on how to use ROP in an ASP.NET Core project here

A few days back I was reading about Railway oriented programming (ROP) on the awesome fsharpforfunandprofit website. Scott Wlaschin (SW) describe a functional approach to error handling not regarding only exceptions but in general how to handle deviations from the happy path. I really liked his approach and I tried to translate the F# code to C# and in this post I'll briefly recap what I've learned.

A tagged union example

· 4 min read

We will talk about tagged union types, how to implement them in C# and how to use them effectively in modeling our domain. Tagged union types will improve your code expressiveness and ability to model all kinds of software domains. They have been extensively used in functional languages, F# itself support out of the box tagged union types under the name "discriminated unions".

AutoToString Visual Studio Extension

· 3 min read

More than a year ago I built my very first Visual Studio extension and published it on the Visual Studio Marketplace. I was working on a web service that passed around a lot of data and in order to log input and output of the endpoints whenever needed I often wrote code like this

Attesa Bus Android App

· 2 min read

Today I tried flux and the dart language from Google, it was easy and fast, I was able to develop a simple app with material UI in a couple of hours. The app fetch informations about bus waiting time using the bus stop id from Rome transportation operator ATAC. There is no API for that so the app just fetch the web page and parse it to retrieve the informations.

ASPNET Core on CentOS

· 8 min read

Today I experimented with the DigitalOcean Cloud and the aspnet core deploy on a linux server. Specifically I wanted to deploy a sample .net core web app on a CentOS 7 server using nginx as a web server. I have no experience in managing a linux server or using nginx or deploying aspnet core to linux in general, however I do have some experience with the bash and the linux environment.

Sample log4net config nuget packages

· One min read

Sample log4net config nuget packages

Everytime I install the log4net nuget package I have to lookup, on the internet or on my other project, how to modify the app.config or the web.config in order to make log4net work.

I decided to create a few nuget packages with sample configs and a small readme in order to easily configure log4net. It took some trial & error but I managed to create a couple of them. The source for the packages in at log4net-config repository.

In order to build the package just run "nuget pack" in the folder with the *.nuspec file.

Enjoy!