Every real world application will always consist of a number of classes each one responsible for some functionality. Sooner or later, these classes will need to communicate with each other. For example, class A needs to ask class B to do something by calling one or more of class B methods.
Achieving this is easy by instantiating class B within class A. To do so, we could for example have a field member of type B inside class A and then instantiate class B inside class A c-tor. As an example, let’s consider Logger class and Processor class below
The purpose of this article is to introduce the topic and encourage discussion about unit tests with a goal to agree and implement good unit testing practices to improve code quality. This article does not discuss methodologies such as TOD, TDD, TDD&D, BDD but simply provides reasons and explanations why unit tests are important and why they are important to be written at an early stage of development (TDD).
There are number of testing types that should be performed on an app before its release such as unit tests, integration test, UI tests but the unit tests are most common.
Barcode scanners are used almost everywhere and as a result, we often need to implement them in our applications.
However, most article outthere talk about implementations using vendor SDKs, EMDKs, libraries, packages etc. You need to add these to your application. Examples I was able to find had no depth, no explanation of terms, or had no clear explanation why processing barcodes one way is better or worse than doing it another way.
This article explains why you may or may not need these SDKs at all with the focus on cross-platform mobile applications. I will show how to implement…
Disposable pattern is used to help with the implementation of finalizers and IDisposable interface provided by .NET to allow developers to manually release any unmanaged resources as soon as they are not needed any more.
In order to better understand this pattern, we need to get better understanding of computer memory. In particular, heap memory and garbage collection, referred as GC from now on.
Garbage collection (or GC) is initialized by CLR. It segments heap memory for better management of objects on the heap. For that reason, we also call it managed heap.
Each managed process such as the one…
Visitor pattern is often described as one of most complicated pattern in GoF book. The purpose of this article is to explain this extremely useful pattern is simple terms.
So, what is visitor pattern?
Visitor pattern allows you to separate algorithm logic from an object structure on which it operates by adding new functions to classes without modifying them in order to design flexible and reusable classes. Therefore, we can say that visitor pattern allows creation of lightweight classes by abstracting their functionality.
If you need more theory on that, check this great wiki article on visitor design pattern https://en.wikipedia.org/wiki/International_taxation
This is second part of my post about threads in .NET. To see first part, check Threading in .NET — Part 1.
Thread class allows you to create and manage threads. You can set threads priority and query or change their status. In next example, we’ll use Thread class to run a method on separate thread. The method does not receive nor return any parameters.
Non-parameterized thread example00000000000000011110000000000111111
The comments in the example above are self-explanatory. The important parts worth mentioning are the calls to Thread.Sleep and Thread.Join methods.
Thread.Sleep(0) will signal OS that…
This article does not cover TPL but discusses general threading concepts.
If your computer had only one CPU and could execute only one operation at a time, then in case of a long lasting operation (say a large file download), it would simply hang and you would have to wait on it to finish before being able to do anything else. Moreover, if the long lasting operation had a bug causing it to never end then all you could do to stop it is to review your machine.
Nowadays, computers have multi core CPUs or multi CPUs. In addition, applications…
Software Engineer at Squirrel Systems