Goal setting

Each year, people will make new year resolutions for the next year. How can you set goals that will succeed the next year?

Read More…

Posted in Personal growth at December 31st, 2017. No Comments.

The art of writing unit tests

With keeping up the quality of your code comes writing unit tests. In its origin, a unit test tests the behavior of a method of a certain class. People tent to fall into writing more integration of system tests, where they test several components at once. Unit tests then become very hard to maintain. What does a good unit test consist of and what do we test?

Read More…

Posted in Uncategorized at December 27th, 2017. No Comments.

Prevent subscribing to an event twice in c#

Events in C# use the observer pattern, where an observer can subscribe itself to event generated by a subject. Within C# the observer can subscribe itself multiple times to the subject. When the subject fires the event, the observer gets multiple events.

The best way to prevent is to be keen on the life-cycle of your events; subscribe at the right place at an event en un-subscribe from the event also at the right place. How can we have a defensive mechanism, that prevents us subscribing multiple times at an event?

Read More…

Posted in C# at December 20th, 2017. No Comments.

Using libraries in a clean way

The software we write, most of the times depend on third-party libraries. Take for example Log4Net or a device driver. The problem in many projects is that the third-library libraries are much interwoven with the production code.

Herein lies a number of problems:

  • What if you want to change the library you are using?
  • What if the structure the library uses does not meet your design?
  • How about unit-testing (think of the fact the library might use local resources like physical devices)?

Uncle Bob states in his clean architecture that within a good design, the whole application isn’t aware of these third-party libraries. Think of a plug-in like ReSharper. At Visual Studio they didn’t have to change anything in their code to support the ReSharper plugin. Only the plugin knows about the existent of the other part of the software.

How can we create such an isolation and separate our libraries from our main architecture?

Read More…

Posted in Design patterns, Unit testing at December 12th, 2017. No Comments.