The behavior of a complex system is often complicated. When we try to implement a complex behavior in the program, that complexity is generally not recognized at first, so the behavior is represented as a single method. Gradually that method grows and grows, gaining more lines, more parameters, and more temporary variables, until it is a monstrous mess. This post explains a few patterns to refactor complicated methods.
Since I started learning to program, one of the most confusing topic has always been how to pass data, without having unintended side effects. Sometimes, we want the data to be immutable, sometimes we do want to modify it within a method. Eric Lippert’s Essential C# does a wonderful job of explaining this topic in depth. This entry tries to summarize my understanding and how it works in C#.
Software development is difficult. Especially if you are working on a 25-year old enterprise software that has gone through multiple platforms, technologies, and has seen multiple generations of developers. All of which makes it hard to understand and difficult to develop. What can we do as developers? Turns out, a lot.
I was really struggling with XML this week at work. Spent hours banging my head to parse a simple XML document. According to pragmatic programmers, I was programming by coincidence, without any clear plan, just hoping to get the code working somehow, and failing completely.
Sometimes, we need to find out if an element is a member of a given set or not. There are many algorithms which solve this problem. However, many are not efficient for large datasets and restricted memory. A good example is a dictionary on an iPhone. While typing, the application needs to verify if the word is in the dictionary or not. The dictionary is huge, and there is just not enough RAM to hold all words. How to find out all the typos? Luckily, there’s a way.