There Are Only Two Roles of Code

All code can be classified into two distinct roles; code that does work (algorithms) and code that coordinates work (coordinators). The real complexity that gets introduced into a code bases is usually directly related to the creation of classes that group together both of these roles under one roof. I’m guilty of it myself.  I would say that 90% of …

Wrapping Callbacks

I’ve recently had the problem of trying to display a progress dialog when executing an asynchronous operation and to dismiss that progress dialog when the operation completes. I wanted to build a way to do this that is generic to my application, so that it would work with any asynchronous operation in order to reduce duplication of writing progress dialog …

Making Switch Refactorings Better – Defaultable Dictionary

I’ve written before on the idea of refactoring a switch to a Map or Dictionary. There is one major problem that I have been running into though.  Switch statements and dictionaries are not functionally equivalent for one major reason… Switches allow for default I kept struggling with this when I would implement a dictionary to replace a switch.  How can …

Back to Basics: Mock Eliminating Patterns

In my previous post I talked about unit testing without mocks.  I gave some examples of how I had done this in some of my real code from PaceMaker. This time I want to take a look at some of the common patterns we can use to extract parts of our code into dependency-lite or dependency-less classes that we can …

Back To Basics: Unit Testing Without Mocks

In my last post, I revealed my conclusions regarding what to do instead of misusing IoC containers and interfaces all over your code mostly for the purpose of unit testing. One of the approaches I suggested was to focus on writing level 1 or level 2 unit tests and occasionally level 3 unit tests with 1 or possibly 2 dependencies …

Solving Problems, Breaking it Down

Right before the holidays, I said that you had better learn how to solve programming problems. This time I am going to try and give you some good tools to enable you to get good at solving programming problems.  (Really algorithm type problems specifically.) Common mistakes When most programmers are given a programming problem in an interview, they make several …

Solving Problems, You Better Learn How

It is astounding how many developers can write and maintain large enterprise systems dealing with all kinds of complex logic, database access, etc and cannot for the life of them solve a moderately difficult programming problem given in an interview in less than 30 minutes. It is also astounding how many developers that can not write even a single line …

Back To Basics: Sorting

Why is sorting so hard? One of the most common misunderstandings and frustrations I see from developers is around sorting. Almost every developer has faced needing to sort a list of things in some manner in their development careers.  Many developers end up fumbling through it, looking for an example from the web and then copying that example, not really …