Latest Posts Under: Design Patterns

I blogged about tiny refactorings not too long ago. I’ve even added an example showing such a refactoring in my game. I’m reading Refactoring to Patterns, and figured that the refactorings I’ve mentioned have a name; it’s called the Compose Method. In the book it even has its own chapter (Chapter 7 “Simplification”), where it also refers to other great patterns to help you improve your maintainability of your code.

Did you ever need to just have an instance of a class you cannot instantiate because the default constructor is not available? Do you want to create a test instance just to be used in unit tests? Don’t want to break up the design of your code just for testing? This post might help you: Sample code: public MyClass { final int someField; private MyClass() { // may not use this someField = -1; } public MyClass(int someFieldValue) { someField = someFieldValue; } int getSomeField() { return someField; } } So lets say this class… Read Article →

As I have promised in my previous post, I would post an example of small refactorings in order to greatly improve the readability and understandability of code. I own a little project called Dune II – The Maker, and I started writing it a little over 10 years ago. In those years I have learned a lot. I did not have much time in those days to apply my new knowledge to the project. You could say the software was rotting. In order to make it better I need to refactor a lot and I… Read Article →

More and more I am being intrigued by the power of a small code refactorings. The positive impact it has on the readability, the maintainability and understandability of your code is great. It keeps code clean(er) and since the changes you make are really small (I’ll demonstrate how small), the chance they will break things is small. Of course, with unit tests (you are writing them right?) making sure you did not break anything: a small refactoring is a low-risk high-benefit practice. In my experience, small refactorings are undervalued. In fact, I undervalued them much myself since… Read Article →

Scroll To Top