Category Archives: Software Development

Post about software developing. Usually a solution to a particular problem, a code sample, etc.

How to check for duplicates

Say you have an IEnumerable<T> of some sort and you want to check if it contains any duplicates. How do you do that? Terrible solution I needed to do this a while ago and the first solution that hit me wasn’t exactly good. Linq has method called Distinct, which returns the distinct items in a sequence (weeds [...]
Posted in Software Development | Tagged , , , | Leave a comment

Test-Driven Development: By Example

I earlier wrote about the book, The Art of Unit Testing, which I finished a while ago. That book was very good and was focused on how to write good unit tests. It also mentioned Test-Driven Development, TDD, but not too much. The book I read next, which I finished a few days ago, was [...]
Also posted in Reviews | Tagged , , , | Leave a comment

How to test asynchronous events

The other day I had to test that an event was raised after some asynchronous work had been done. And since I currently am a total test newbie, this was a new thing for me. Say we have this simple shell of a class: public class Worker {     public event EventHandler<eventargs> Done;     public void Start()   [...]
Posted in Software Development | Tagged , , , , | Leave a comment

Generics and checking for null

When writing C#, in Visual Studio, using generics… have you ever tried checking for null? I have always found that a bit of a hassle. Say we have this method which returns the subject if it is not null, and the result of a createNew() function if it is null. public static T NewIfNull<t>(this T subject, [...]
Posted in Software Development | Tagged , , | Leave a comment

Project Euler: Problem 25

The Fibonacci sequence is defined by the recurrence relation: , where and . Hence the first 12 terms will be: … The 12th term, , is the first term to contain three digits. What is the first term in the Fibonacci sequence to contain 1000 digits?
Also posted in Project Euler | Tagged , , , | Leave a comment

Project Euler: Problem 16

and the sum of its digits is. What is the sum of the digits of the number ?
Also posted in Project Euler | Tagged , | Leave a comment

The Art of Unit Testing

Have you gone through three years of computer science bachelor degree fun (or anything similar) and pretty much not heard a word about testing? Or have you heard from all your teachers that testing is extremely important, but never learned how to even write one? That has been the case for me. Testing is important, [...]
Also posted in Reviews | Tagged , , , | 3 Comments
  • Twitter Facebook YouTube last.fm LinkedIn Google vimeo Technorati RSS feed
  • This would be meGreetings! I am Torleif Berger, 24 years old, a Seventh-Day Adventist and currently working as a software developer. Otherwise, not much to tell. Although I do juggle a bit...