With a clickbait-y title like This One Simple Change for Better Class Naming Will Blow Your Mind, this short article really gives one little trick that makes naming some of our classes easier. Check it out, guys!
Jumping around between multiple languages can help you notice some differences between idioms and best practices in different languages. One of the more interesting differences has to do with one function doing multiple things. Continue Reading
I’ve got a shorter one this week. Partially, that’s because I was part way through a post before deciding to scrap it. Partially, it’s because I’ve written a few mid-week blurbs this week. Lastly, it’s because I don’t think I could stretch this article to be all that big. 🙂
Generally, people are told to name methods and functions as verbs. If it’s not a verb, it’s a noun, and therefore an object (assuming it’s an OO language). In most cases, this is true, and, if you’re not sure whether to use the simple verb form or the form I’m about to mention, you should go with the verb form to be safe. Continue Reading
There’s a fair amount of ideas out there about what you should name your unit test methods. Until recently, I had followed a variation of BDD‘s naming scheme, “shouldDoSomethingWhenGivenSomething”. BDD-esque naming is still what I consider the best naming scheme that I’ve seen out there (what I’m going to show you in this post doesn’t count for some interesting reasons that may or may not be clear to you when you’re done reading it). It’s certainly not bad, but I’ve got a few bones to pick with it, and, eventually, a solution.
Problem #1: Difficult Searching/Distinguishing
First off, BDD’s naming convention lends itself to long names that have repeated parts between different tests. For example, “shouldThrowMyExceptionWhenGivenInvalidParameter1” and “shouldThrowMyExceptionWhenGivenInvalidParameter2”. This can be a pain to deal with when a test suddenly goes red and you have to find it among all your other test methods by name in order to see what might be the problem. Continue Reading