Author Archives: Torleif

Interlude

Not much is happening at the moment. Well, actually quite a bit is happening. It’s just that I find myself in a rather non-eventful interlude of some sort. Last Friday (January, 29th) I had my last day at SMS Development & Support AS where I have been working for the last 1.5 years. It was [...]
Posted in Personal | Tagged , , | 4 Comments

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 [...]
Posted in Reviews, Software Development | 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?
Posted in Project Euler, Software Development | 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 ?
Posted in Project Euler, Software Development | Tagged , | Leave a comment
  • 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...