Skip to content

AdrianStrugala/SolTechnology.Core

Repository files navigation

SolTechnology-logo

SolTechnology.Core

Modern redable coding

"Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer's intent but rather is full of crisp abstractions and straightforward lines of control."

~Grady Booch author of Object Oriented Analysis and Design with Applications

Core Libraries

The SolTechnology.Core repository contains a set of shared libraries. This is a foundation for CQRS driven applications using basic Azure technologies. The libraries support a modern coding approach presented in the example application called "Tale Code".

Documentation Nuget
Sql Database
Blob Storage
HttpClients
Message Bus
Guards
Authentication
Logging
Scheduler
CQRS
Api
Cache

Tale Code

The idea of clean and readable code stays with me from the very beginning of my career. As for book lover and amateur writer, this is the most natural part of programming.
In the Tale Code approach, I am trying to summarize all the information about coding, design, automation and configuration that I have learned over the years. The Tale Code rule is simple:

"Make your code pleasure to read like a tale."

~Adrian Strugala

The TaleCode application is the most common case that came to my mind. Every night some data is fetched. Then it is validated and stored. Users have the possibility to query the data. The queries are expensive and require additional data manipulation.
To solve the application flow the CQRS approach is implemented. It is interesting from a technological perspective. Uses SQL, no-SQL databases, Azure Service Bus, Scheduled Tasks, Authentication, and Application Insights logging.

The Code Design is the main goal of TaleCode application. The Code is organized in the most redable way I was able to think of. Take a look at example Query Handler:

    public async Task<CalculateBestPathResult> Handle(CalculateBestPathQuery query)
    {
        var cities = query.Cities.Where(c => c != null).ToList();
        var context = new CalculateBestPathContext(cities.Count);

        await _downloadRoadData(cities!, context);
        _findProfitablePath(context, cities.Count);

        var orderOfCities = _solveTSP(context.OptimalDistances.ToList());

        CalculateBestPathResult calculateBestPathResult = new CalculateBestPathResult
        {
            Cities = cities!,
            BestPaths = _formPathsFromMatrices(cities!, context, orderOfCities)
        };
        return calculateBestPathResult;
    }

Compact and clean.
Sample Command Handler using funcional-like notation:

        await Chain
            .Start(() => GetPlayerId(command.PlayerId))
            .Then(SynchronizePlayer)
            .Then(CalculateMatchesToSync)
            .Then(match => match.ForEach(id =>
                SynchronizeMatch(id, command.PlayerId)))
            .Then(_ => new PlayerMatchesSynchronizedEvent(command.PlayerId))
            .Then(PublishMessage)
            .EndCommand();

I have summarized the knowledge and decisions into three chapters.
Enjoy your reading!

1. The Design
2. The Automation
3. The Quality

Some ending words