Today, we’ll be talking about something controversial: static methods. I have yet to read anything that says static methods are good and useful, other than Effective Java recommending them in the use of static factory methods. There are some really interesting (and somewhat dumb) arguments out there against them that rarely, if ever, even get explained. Notably, I’m providing a rebuttal to the article, Utility Classes Have Nothing to do With Functional Programming.
Today, we’re going to look at the good and bad of static methods; what they’re good for and what they’re not.
I was asked to review a new book by Packt Publishing called Test-Driven Python Development. I was really excited because it combined two of my three favorite programming topics that I can’t seem to stop reading about: Python and TDD/Unit Testing.
The book has many editing mistakes, but does a great, in-depth job of explaining TDD and good testing in Python. Continue Reading
Sometimes, you may hear about dependency injection done via a getter method, which subclasses override or mock frameworks fake for testing. It allows the class to have a set dependency that is actually hard coded, but can be “injected” if need be. Continue Reading
Today’s article is something a little special. It’s the first article where I use code from my current personal project for examples. You will be getting “real world” examples and not silly, made-up examples like my Scientist and Pen example in my factories article.
Sorry, I was super busy and unable to write a blog post for this week. Instead, I’ll link you to a post I found recently that helps you to decide what to test next in order to incrementally create an algorithm. Check it out. Continue Reading
Sometimes, when you make a class, it directly instantiates an object to use in its methods. For example:
public void myFunc()
MyType object = new MyType();
this.thingy = object.getSomething();
This is generally viewed as bad, since you’re tightly coupling your class to the instantiated one. “But,” you say, “I know that I will never use any other class, and I certainly don’t want users of the class to be supplying alternatives to use.” These concerns are mostly valid, but they leave out a very important thing to pay attention to: testing. Continue Reading
I’ve done a few posts on the Hamcrest library, and I really do enjoy using it, but there are a few changes I would love to make to it. I understand most of the design decisions that they made, but I think some of them weren’t really worth it.
Most of the changes I would make to the library help to lighten the load of Hamcrest, since I feel like there are a few things that weigh it down unnecessarily. This is why I call my changes Litecrest. It won’t be an actual library; this is all just thinking aloud. I also hope that you’ll learn a little about designing libraries from this. Continue Reading