I was originally planning on writing something about the Cake pattern here, but after reading a lot more about it, I’ve decided it’s not as bad as I thought. I mistook one variant of it (which involved essentially having all methods of all classes available to you) with something a little more sophisticated. If you want to know about the pattern, I recommend Real World Scala: Dependency Injection (DI) by Jonas Bonér.
Here’s something fluffy that I’ve wanted to write about for a while. Often, when working on something, we become fixated. We understand that there are other possibilities, but we don’t consider them; the solution we have in mind is so good that if we could just get it working, everything would be amazing. Unfortunately, people in this position never seem to actually get the work off the ground.
Almost always, getting into this position requires a simple mistake made early on. Often, it will be an invalid assumption, but a typo or an error are just as likely. They all boil down to one thing: not thinking enough, but just doing. After several minutes or hours of banging our heads against the wall, we wonder what we ever did to deserve this.
And the answer is simple: we didn’t allow ourselves to think differently.
There are many ways in which you can achieve this. Taking baby steps is a great approach, as long as you know which direction you’re walking. Sometimes, though, you need a better catalyst. At that point, you should go and make a sandwich. Or have a nap. Go for a swim. Read a book about vampires, pirates and dinosaurs. Lie in the sunshine (or the rain, if you’re in Britain like me). Go home, play some video games, chat to your partner about their day and have a good night’s sleep.
When you come back, things will be different.
The human brain is an exceptionally powerful machine, as long as we operate it right. It’s not a computer. It doesn’t have distinct rules on how input gets translated to output. Sometimes it’s important to think about anything but the task at hand if we want to really consider all approaches to solving the problem.