Category: Code

  • How to test a private method of a class?

    by

    in

    Today I got a question from my collegue how to test a method that is marked as private on a class? My first reaction was ‘well just make it public’ but of course that would break the class encapsulation, and there are ways to actually test a private method without breaking this encapsulation. What you…

  • Beautiful Code – binary search

    Somewhere in chapter seven of the book Beautiful Code the following challenge is given: If you have never implemented binary search, or haven’t done so in a few years, I suggest you try that yourself before going forward; it will give you greater appreciation for what follows. Well, binary search? What was that again? Well,…