I released the starter package of my Test With Spring course. Take a look at the course >>

The Best Comments of October 2015

Thumbs up star

I think that the best part of writing a blog is to get comments from my readers.

Because I have learned a lot from my readers, I want to “reward” the best comments, help you to learn new things, and (hopefully) encourage people to leave more comments.

The rules are simple:

  • I select X best comments that were left on my blog during the previous month.
  • I link to these comments and explain why I chose them.
  • If the author of the selected comment has a blog, I add a link to her/his blog as well.

Enough with chit chat. The seven best comments of October 2015 are (in chronological order):

The Seven Best Comments of October 2015

Rogerio argues that field injection is a better choice than constructor injection. I selected this comment because this is an evergreen (and a bit frustrating) discussion. I hope that my answer clarifies my thoughts about this matter. If it doesn’t (or you think that I am wrong), feel free to say so!

Pradeep wanted to know why his/her Querydsl query, which has two subqueries, throws a NullPointerException. This comment deserves to be on this list because I couldn’t answer to Pradeep’s question. If you have an idea what could be wrong, could you leave a comment to that blog post. Thank you in advance. :)

Jose left a comment that exposes the downside of mock objects, and that is why this comment deserves to be on this list. The thing is that you can configure a mock object to return objects that “violate” the contract specified by the interface of the mocked class. That is why writing only unit tests is not good enough, and I hope that my answer made this clear.

Dan Carter reminded us about the fact that even small projects are important to our customers. I decided to add this comment on this list because I think that some developers don’t give small projects the attention they deserve. By the way, I agree with Dan.

Henning wanted to know if it possible to use constructor injection for optional dependencies. This comment deserves to be on this list because it is indeed possible to use constructor injection for both mandatory and optional dependencies (if you use Spring).

Hichem asked if I can clarify my definition of a domain service. This comment deserves to be on this list because domain services are a crucial part of a domain model. I tried to answer to Hichem’s question, but I found out that it is not an easy task. That is why I decided to provide a link to an excellent StackOverflow discussion.

Gaetano didn’t know how to write assertions for the content of a collection, which is stored to the Model, by using the Spring MVC Test framework. I selected this comment because this is a quite common use case. By the way, my answer helped Gaetano to solve his problem.

About the Author

Petri Kainulainen is passionate about software development and continuous improvement. He is specialized in software development with the Spring Framework and is the author of Spring Data book.

About Petri Kainulainen →

0 comments… add one

Leave a Comment