Category Programming

Be aware of copying in Go

Some bugs are very hard to find and to reproduce but easy to fix. To avoid them, it’s helpful to know how the tools we’re using work under the hood. From this article, you’ll learn what shallow and deep copy are and which errors you can avoid thank’s the knowledge about them. Can you find a problem with the code below? q1 := NewQuestion(1, "How to be cool?") q1 = q1.

How to send multiple variables via channel in golang?

Channels in golang are referenced type. It means that they are references to a place in the memory. The information can be used to achieve the goal. Firstly, let’s consider using structs as the information carrier. This is the most intuitive choice for the purpose. Below you can find an example of a struct which will be used today. type FuncResult struct { Err error Result int } func NewFuncResult(result int) FuncResult { return FuncResult{Result: result} } The idea is to create a channel from the struct, pass the channel to a function and wait for the result.

Entity and value object

Knowing the basics is the key to understanding more complex concepts. After reading this post you will know what are entities and value objects and find out differences between them. When you pay for something at a shop it’s not important which exactly coin you choose. The most important thing to the shop assistant is their value. It does not matter if you give him coin from the left or right pocket.

Services in DDD finally explained

I’ve noticed that there is always a challenge of understanding what services are in a context of domain-driven development and what is the difference between a service in an application, domain, and infrastructure layer. Domain-driven design made a lot of cleanup in the IT environment and conquered the hearts of programmers. Eric Evans is one of the most famous people who promote this not so a new way of developing software.

Mutational tests

When you have a very simple application it’s not so important to test every edge case but in a project, in the very complex domain, the priority of it will increase. The more high-quality the tests, the more high-quality the code. Mutational tests will help you with making sure you did not miss some a variant of the flow in your code. How it works Mutational testing is a test which runs other test several times but with a bit changed production code in every iteration.