The Best Comments of November 2015

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 November 2015 are (in chronological order):

The Five Best Comments of November 2015

Paul argued that the unit tests of my Spring MVC Test tutorial don't test the controller logic because I replace service objects with mock objects. This comment deserves to be on this list because Paul made one very important point: there is no one right way to select the size of the tested unit. My answer explains why I want to isolate the external dependencies of the tested class and keep the tested unit as small as possible.

Dominik wanted to know how he should model a situation where two entities are "linked with each other", but they don't belong to the same aggregate. This comment deserves to be on this list because it is a quite common use case. Sadly, it is often solved in the wrong way. My answer describes what is the right way to solve this problem.

Trevor couldn't add integration tests into his Gradle build by following the instructions given on my blog. This comment deserves to be on this list because I couldn't solve his problem. Maybe you can help him?

Gaetano couldn't write a unit test that invokes his custom validator. I selected this comment on this list because my original advice didn't solve Gaetano's problem. Luckily, my second answer did the trick.

Joro pointed out two good reasons why our service classes should return DTOs instead of entities. This comment deserves to be on this list because it's important that you understand why returning entities is not a good idea (even though it is a lot easier). By the way, Joro has a blog. Check it out.

0 comments… add one

Leave a Reply