The secret "formaction" attribute

Recently I came across a use case of a form which needed two submit buttons. One submit button would just save the data for further edition. Second submit button would save the data and lock it, so you wouldn’t be able to edit it anymore. The best way I know to solve this task is to use formaction attribute. It’s not really a “secret” (as in headline) but it’s lesser known. There is only a one use case for it, but when you need it then there is probably no better way. ...

April 21, 2018 · 2 min · Zbigniew

Value tuples C# 7

Value tuples is one of the features added in C# 7. I’m going to show you why it was introduced to language and how you can use it. Tuple Before we start with value tuples let’s take a look at regular tuples. What’s a Tuple? Basically it’s a set of grouped properties. You can use it to: quickly group related variables pass multiple related values as a single parameter return multiple values from method General characteristics of a Tuple: ...

April 13, 2018 · 3 min · Zbigniew

C# merge dictionary and other tricks

Dictionary is a handy class. It’s a collection of key-value pairs. It is a hash table which means that it has to have unique keys (according to equality comparer). Each key is mapped to a value. Retrieving a value by key is very fast. There are many things you can do with it. In this article I’m going to show you some tricks that may come in handy sometimes. Initializing dictionary In cases when you already have some predefined data you can initialize it using collection initializer. ...

April 6, 2018 · 4 min · Zbigniew

An introduction to unit testing using xUnit.net in .NET Core

Before we get into unit testing we should ask ourselves why would anyone write code to test other code? Is there any reason to do that extra work? It turns out that there are many reasons for that. Firstly, you’re going to make sure that given function works as expected. Secondly, if you decide to change the function, you still have it tested, so in case of some incorrect change you’ll know immediately that something is wrong. Thirdly, your code will have better design, because (once you figure it out) you’ll most likely avoid all dependencies and you’ll make sure that your code is as easy to use as possible. ...

March 30, 2018 · 11 min · Zbigniew

Having trouble learning your first programming language?

You want to learn your first programming language. You read about it a little bit and you decide which programming language to learn. Then you read that big book full of syntax or you watch these programming videos and … nothing. When you open your IDE you can only stare on that blinking cursor, your mind is blank and you don’t know what to do. I’ll tell you why this happens and what to do about it. ...

March 23, 2018 · 6 min · Zbigniew