Vladimir Khorikov
enterprisecraftsmanship.com · Personal blog · on HN since 2015
Vladimir Khorikov writes about software design, unit testing, domain-driven design, and .NET development.
What HN saysHN commenters recommend his posts on when to mock and on testing without mocks, and favor his classical approach to unit testing.
29HN people shared it
7linked it in comments
78stories submitted
1.1Kstory points
2 years agolast shared
2015people per year2026
Most-shared posts
- 1Growing Object-Oriented Software, Guided by Tests Without Mocks4 people · 12 points · first shared 2016 · 1 comments on HN
- 2When to Mock3 people · 60 points · first shared 2020 · 79 comments on HN
- 3SQL vs. NoSQL: you do want to have a relational storage by default3 people · 20 points · first shared 2015 · 2 comments on HN
- 4How I tried to get into game development and failed2 people · 298 points · first shared 2017 · 168 comments on HN
- 5C# and F# approaches to illegal states2 people · 99 points · first shared 2015 · 92 comments on HN
- 6Law of Demeter and immutability2 people · 50 points · first shared 2016 · 36 comments on HN
- 7OOP, FP, and object-relational impedance mismatch2 people · 6 points · first shared 2016 · discussion on HN
- 8Why following software design best practices decreases code complexity2 people · 6 points · first shared 2015 · 1 comments on HN
- 9Test-induced design damage or why TDD is so painful2 people · 6 points · first shared 2015 · 1 comments on HN
- 10What is functional programming?2 people · 4 points · first shared 2016 · discussion on HN
- 11Temporal Coupling and Immutability2 people · 3 points · first shared 2017 · discussion on HN
- 12You are naming your tests wrong2 people · 3 points · first shared 2019 · discussion on HN
- 13DRY vs. Damp in Unit Tests2 people · 2 points · first shared 2020 · discussion on HN
- 14TDD best practices2 people · 2 points · first shared 2015 · discussion on HN
- 15Growing Object-Oriented Software, Guided by Tests Without Mocks (2016)2 people · 1 points · first shared 2021 · discussion on HN
What HN people wrote when they linked it
amw-zero · 2021-08-09
Here’s another review / critique of this book, but with a full implementation based on the author’s grievances: https://enterprisecraftsmanship.com/posts/growing-object-oriented-soft…
The main point of it is to avoid testing via mocks and to also avoid interfaces that are only there for testing purposes. The end design is extremely simple, and because it has command / query separation, the actual logic is trivially testable.
Give it a read. I love Growing Object oriented software guided by tests as well, these are all just different approaches with different mindsets.
arwhatever · 2021-01-30
Might I recommend this overview? https://enterprisecraftsmanship.com/posts/when-to-mock/
I more understand the Martin Fowler article quite well, but only after struggling with it and revisiting it (sporadically) over several years, and I really think this by Mr, Khorikov gives a much clearer, more straightforward overview.
spawarotti · 2020-09-24
Came here to say exactly that. The author is advocating for mockist style of unit testing, which is quite terrible for many, many reasons. What you are describing is classic unit testing, and this is the way to go.
Good article and book about it:
- https://enterprisecraftsmanship.com/posts/unit-testing-dependencies
- Unit Testing Principles, Practices, and Patterns
kraftman · 2018-08-15
I found this set of articles great for using less mocks and creating less brittle tests: https://enterprisecraftsmanship.com/2015/07/06/how-to-do-painless-tdd/
NicoJuicy · 2022-02-14
I see a lot of complaints from you.
But I should mention that nhibernate is not even in the dotnet foundation and not supported for .net core ( I visited their site and it mentions dotnet framework).
I see this though: https://enterprisecraftsmanship.com/posts/nhibernate-now-supports-net-…
So the issue is mostly nhibernate?
vkhorikov · 2017-10-06
Do you need an ORM? http://enterprisecraftsmanship.com/2015/11/30/do-you-need-an-orm/
stemmlerjs · 2019-04-18
> How many places in your code create new users, and how many places in your code need to validate users? If the answer is “many,” you have serious design problems that should not be solved by introducing more classes but by restricting how many different areas of code do the same job.
Consider an application where you can edit and add users. Consider that you can also add users to groups and remove users from groups. Consider that you might also be able to add policies to users. These are a few different areas in code where you might need to create an instance of a User.
This is exactly what we're doing; we're limiting the amount of places where valid users can get created. The User domain object and it's invariants are validated right here at the model.
If there was an invariant saying that users can't have more than 5 policies on them, a user.addPolicy(policy) method would exist right on the user model/aggregate root, and the aggregate root would be responsible for determining if any invariants will be unsatisfied after the operation.
> Also, the private constructors do absolutely nothing. The static factory methods in this blog post could be written the exact same way as a constructor, and they would work exactly the same. The only reason the author uses a static factory method is because that's what he was taught to do in Java.
The reason why I use a static factory method is because it allows you to protect the aggregate invariants (domain logic that deems the…