Work hygiene

Originally I wanted to make a comparison of apps that recalls about short and long breaks, but every app has more or less same functionality, so it is a matter of preference, and also I decided that it is much more important to explain why is worthwhile to use them.

The risk

Working as a white collar worker seems like very comfortable and safe work – I agree with that :), but it doesn’t mean this kind of work doesn’t affect our health at all.

Office workers spent most of their time using a computer. After everybody likes to chill out watching some movies or surf the web. Every ambition person wants to develop herself so they’re working on side projects or learning using online courses.
All of those things could result in many hours spent by sitting, using mouse and keyboard and looking at a monitor.

The sense of sight is probably the most important. Long working on a computer may be really damaging for our eyes, it could lead for example to eye strain and shortsightedness.

For now still, the best input methods are keyboards and mice. Both of them are heavily used. Our hands are in the same position for many hours.
That could lead to the very painful condition like carpal tunnel syndrome (CTS) or tendonitis. Having a problem with wrists probably will force you to take a very long vacation, or you can try to type with your feet (I know the person who really did it).

The last group of health problems is associated with long sitting. Things like occasional back and neck pain don’t sound serious but ignored may create a bigger problem.
There is also very „shameful” disease, which can be caused by long sitting – hemorrhoids.

The cure

There are a few things that could be done in order to prevent those health problems.

The main things, in my opinion, is to take regular short brakes during work. Polish law even regulates such brakes for employees working with computers.
I using software called EyeLeo that recalls me to take two types of brakes. I set up short break for every 10 minutes, and it takes only 8 seconds. The goal of that break is to give some break to eyes.
EyeLeo in reminder pop-up shows what you need to do, for example: „roll your eye”, „blink your eyes”, „look out the window”.
Long break happens every one hour and it takes 4 minutes. During these breaks, I do some exercises for the neck, I stretching my legs by walking around the room.
I’m not super strong about those brakes when I feel very focused I usually skip a break but not more than two in the row.
Regular breaks are very beneficial for eyes, back, neck, legs.

Breaks are important but back pain may appear anyway if deep muscles won’t be stimulated. There are a lot of exercises to stimulate deep muscles, you can also do some sports, but remember to be careful and patient to not get any injury.

There are things we cannot detect by themselves. Our vision deteriorates very slow and is very important to detect this process at its beginning.

In order to prevent CTS and tendonitis, there is need to invest some money into gel pad. I do have gel pad for my mouse and I thinking about big gel pad for my keyboard. Gel pad for a keyboard is not always required. Some keyboards are specially designed to give your wrists some support.

I didn’t mention yet about right posture during sitting, but unfortunately, I can just say that it is important. I want to explore this subject by myself.
Another thing that I would try it is a standing desk. I had an idea to made a poor version of a standing desk by myself, like a putting some stuff under the legs of the desk, but that would require a lot of effort when I would like to change a position between sitting and standing.


All those things I wrote based on my experience, and things that I read in the past. I didn’t provide any proves, because the goal of that post is to point out that there are many things that could damage our health even in comfy office work. There are more appropriate places on the web that describes such things in details.

Micro ORMs

From ADO.NET to EF

When I started to learn to programming I didn’t have knowledge about ORMs. I feel that is the pain in the ass writing all that SQL code, and then I discovered Linq to SQL.

I remember that I was totally in love in that. I wrote a lot off code with it (mostly a bad code 🙂 ).Then I started using EntityFramework

Then I started using EntityFramework. At the begging with database first convention, and then with code first convention.

Slowly I started to discovering weak points of ORMs, like performance, a lot of unneeded data, at sometimes to archive what expected SQL code there was need to spend a lot of time or just write SQL View.

Micro ORMs

Then I discovered micro ORMs. First I used was Massive.

Massive is so small library that even doesn’t have nuget package, it is just a one small code file.


In my current work, I have an opportunity to work with Simple.Data. At the beginning I was very happy using it, it seems relly easy to learn and use, but when I wanted to do something more complicated, like filter records by data from a foreign table, the code began to complicate very fast.

Last thing that finally made me very angry it was its performance in casting to objects. I had to fetch relatively a big chunk of data, over 6k rows because of left joins, and that 6k records should give me 700 objects. I understand that it is not a standard use case, and maybe I made some mistake, maybe there is a way how to do that better, but I didn’t find it. Simple.Data is no longer supported and that thing also didn’t help me to find an answer.


So I made the decision that I have to change Simple.Data to something else. After a short research, I found Dapper.

Dapper, it is an open source project made by StackExchange. They claimed that almost entire data access layer is made with Dapper.

Using Dapper you have to write SQL code by yourself, so thanks to that you have 100% control over it, and at the end, it is more like a data caster, but really good data caster.
StackExchange also developed SqlQueryBuilder, which simplifies creating SQL query a lot.

So to summarize, if you looking for small versatile and supported ORM, you should look at Dapper.

Life balance

Sometimes I think about myself as a lazy guy, and sometimes I think about myself as a workaholic.

I can split my life into two phases, laziness phase, and hard working phase.

During the hard-working phase, I usually do a bunch of stuff, from exercises through reading books up to side projects.
This is my daily routine for a couple of months, but at some point, I going to vacation, or installing the new game to relax, and basically this moment is the end of a hard-working phase.
In my laziness phase, I play lots of games or I’m doing nothing, just wasting a time. I’m master of procrastination. I’m able to be sharp only for ~8 hours daily so I can do my stuff at work and that all.

These phases will be acceptable if the ratio of time spent in both of them will on the hard-working side or at least it will be in middle.
But unfortunately lately that ratio is on laziness side, so I have to change this balance, I have to stop both phases and start the new one ‚Be balanced’ phase.

I have in mind a few things that will help me with being more organized and productive, but in the same time, I won’t be tired.

How to do that:

  • I’ve written down my resolution for the current year. My goal with the resolution was to create them in a way that I can objectively judge if I did them or no. For example, I want to write at least one blog post per month and read one book per two months.
    Previously probably I would set much stronger goals, which in result made me tired, and I will drop off them, so I rather want to start soft.
  • I making log book of my daily activities, so in case if I didn’t make anything useful for a few day, then this logbook will work as a wall of shame, normally I would like to hide it somewhere deep in my brain to not be ashamed of himself.
  • Remove as many as possible things that when I want to be productive.
  • I want to to give myself from time to time a break

So far my plan is working, I’m more productive and it’s very satisfying.

English please

This blog is (and will be) used mostly for describing changes in my pet project (Ilaro.Admin), which fair amount of English speaking people are interested in, so I decided from now on to write blog posts in English.

It will help people to stay updated and also they will know reasons for decisions.

This will be also great opportunity for me to improve my language skills.

Historia zmian | Ilaro.Admin

Ilaro.Admin w prosty sposób umożliwia zapisywanie historii dokonywanych zmian rekordów.

By włączyć tą funkcje należy zarejestrować encje, która implementuje interfejs IEntityChange.

A następnie w bazie danych utworzyć tabele dla tej encji.

Obsługa tej encji przez Ilaro.Admin wygląda nieco odmiennie od pozostałych encji. Z tego względu nie będą działać wszystkie możliwości konfiguracji. W przyszłości stworze interfejs do konfigurowania tylko tej encji tak by było jasne co zostanie uwzględnione a co nie.

Podstawowe rzeczy takie jak ustawienie nazwy tabeli i kolumny oczywiście działają.


MaxLength a StringLength

W .net sa dwa atrybuty, które wydawać by się mogły, że robią to samo.
Obydwa dziedziczą po ValidationAttribute, a więc obydwa mogą posłużyć do konfigurowania walidacji modeli we ASP.NET MVC.

MaxLength wykorzystywany jest przez EntityFramework w celu określenia maksymalnej długości pola w bazie danych.
StringLength jest bardziej ogólną implementacją walidacji długości pola.
Pozwala on na określenie minimalnej długości. Dla tego atrybutu możliwe jest wygenerowanie atrybutów html potrzebnych do walidacji client side. Dla MaxLength nie zostaną one wygenerowane, czyli walidacja w java script nie będzie działała.

Podsumowując, w ASP.NET MVC w view modelach powinno się używać StringLength.

Domyślne wartości | Ilaro.Admin

W poprzednim wpisie na temat usuwania rekordów wspomniałem o metodzie OnDelete, która ustawia wartości properties podczas usuwania.

Istnieją jeszcze dwie analogiczne metody, OnCreate i OnUpdate.
Każda z nich ustawia domyślne wartości podczas określonej akcji, OnCreate podczas tworzenia rekordu, OnUpdate podczas edycji rekordu i OnDelete podczas usuwania (soft delete).


Usuwanie rekordów | Ilaro.Admin

Podczas usuwania rekordu zawsze jest wyświetlana strona do potwierdzenia.

W wersji v2 będę to chciał zmienić. Chciałbym dodać opcję potwierdzania w oknie modalnym (lub w podobny sposób) a także możliwość kompletnego usunięcia potrzeby usunięcia, w przypadku gdy usuwanie encji jest robione poprzez soft delete. Po usunięciu pojawiałaby się opcja umożliwiająca cofnięcie usuwania.

Klucze obce

Podstawowym problemem podczas usuwania rekordu są jego zależności.
Trzeba zadbać o to by przed usunięciem rekordu inne rekordy nie będą miały do niego referencji.
Można to zrobić na dwa sposoby, albo poprzez usunięcie rekordów z referencjami, albo odpięcie usuwanego rekordu od rekordów z referencjami.


Refaktoryzacja inicjalizacji encji | Ilaro.Admin

Jak było?

Do tej pory inicjalizacja atrybutami była zaszyta w logice encji, co oczywiście nie powinno mieć miejsca. Niektóre rzeczy były inaczej inicjalizowane używając atrybutów a inaczej używając fluent konfiguracji.

Kolejną złą rzeczą było inicjalizowanie obiektu od razu po jego utworzeniu, co powodowało, że w metodzie Admin.Initialise()  musiałem wykonywać dodatkową konfiguracje, ponieważ niektóre rzeczy zależą od konfiguracji innych rzeczy.
Na przykład jeśli nie został określony template edycji to jest on określany automatycznie, co jednak zależy od kilku innych rzeczy, taki jak typ zmiennej, data type zmiennej (Html, Password, itd.), a także uwzględnia czy zmienna jest kluczem obcym.

Dodatkowym problemem byłoby to, ze jeśli chciałbym dodać nowy sposób inicjalizacji, na przykład czytanie z pliku xml lub json, to stopień komplikacji i zależności tym bardziej by wzrósł.