Enterprise Craftsmanship https://enterprisecraftsmanship.com/ Recent content on Enterprise Craftsmanship Hugo -- gohugo.io en-us Tue, 25 Oct 2022 00:00:00 +0000 Generic types are for arguments, specific types are for return values https://enterprisecraftsmanship.com/posts/generic-types-arguments-specific-types-return-values/ Tue, 25 Oct 2022 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/generic-types-arguments-specific-types-return-values/ <div class="paragraph"> <p>Today, we&#8217;ll discuss the following guideline: you should use the most generic types possible for arguments and the most specific types possible for return values.</p> </div> Modeling Relationships in a DDD Way https://enterprisecraftsmanship.com/posts/modeling-relationships-in-ddd-way/ Tue, 19 Apr 2022 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/modeling-relationships-in-ddd-way/ <div class="paragraph"> <p>Let&#8217;s talk about modeling of relationships, including the dreaded many-to-many relationships, in a DDD way.</p> </div> Encapsulating EF Core Usage: New Pluralsight course https://enterprisecraftsmanship.com/posts/new-course-ef-core-encapsulation/ Mon, 11 Apr 2022 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/new-course-ef-core-encapsulation/ <div class="paragraph"> <p>My new online training course about <a href="https://enterprisecraftsmanship.com/ps-ef-core-2">Encapsulating EF Core Usage</a> went live.</p> </div> Collections and Primitive Obsession https://enterprisecraftsmanship.com/posts/collections-primitive-obsession/ Wed, 16 Feb 2022 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/collections-primitive-obsession/ <div class="paragraph"> <p>Does the primitive obsession anti-pattern apply to collections? In other words, should you introduce a custom class for a collection?</p> </div> How to Assert Database State? https://enterprisecraftsmanship.com/posts/how-to-assert-database-state/ Wed, 15 Dec 2021 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/how-to-assert-database-state/ <div class="paragraph"> <p>Today, we&#8217;ll discuss a question that relates to my <a href="https://enterprisecraftsmanship.com/book-amazon">Unit Testing book</a>: how to assert the state of the database?</p> </div> Should you Abstract the Database? https://enterprisecraftsmanship.com/posts/should-you-abstract-database/ Tue, 07 Dec 2021 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/should-you-abstract-database/ <div class="paragraph"> <p>This article is inspired by a tweet that I thought would be a good topic for discussion: should you abstract your database?</p> </div> Database and Always-Valid Domain Model https://enterprisecraftsmanship.com/posts/database-always-valid-domain-model/ Tue, 31 Aug 2021 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/database-always-valid-domain-model/ <div class="paragraph"> <p>Today, we&#8217;ll talk about an important question: how does the application database fit into the concept of Always-Valid Domain Model?</p> </div> <div class="paragraph"> <p>In other words, is the database part of the always-valid boundary or should you consider it an external system and validate all data coming from it?</p> </div> Specification Pattern vs Always-Valid Domain Model https://enterprisecraftsmanship.com/posts/specification-pattern-always-valid-domain-model/ Tue, 27 Jul 2021 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/specification-pattern-always-valid-domain-model/ <div class="paragraph"> <p>There&#8217;s an interesting controversy between two DDD topics: the Specification pattern and the Always-Valid domain model.</p> </div> Nulls in Value Objects https://enterprisecraftsmanship.com/posts/nulls-in-value-objects/ Thu, 03 Jun 2021 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/nulls-in-value-objects/ <div class="paragraph"> <p>Today, we&#8217;ll discuss an interesting use case of handling nulls in value objects. Should you put <code>null</code> inside the value objects themselves or decorate those value objects using the nullable reference type notation (<code>?</code> or <code>Maybe</code>)?</p> </div> Validation and DDD: New online course https://enterprisecraftsmanship.com/posts/new-online-course-ddd-validation/ Thu, 13 May 2021 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/new-online-course-ddd-validation/ <div class="paragraph"> <p>My new online training course about <a href="https://enterprisecraftsmanship.com/ps-ddd-validation">Validation and DDD</a> went live.</p> </div> Static methods considered evil? https://enterprisecraftsmanship.com/posts/static-methods-evil/ Thu, 01 Apr 2021 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/static-methods-evil/ <div class="paragraph"> <p>Are static methods good or bad? Over the course of my career I did a full circle on this topic. In this article, I&#8217;ll try to describe this evolution and the reasoning behind it.</p> </div> Always-Valid Domain Model https://enterprisecraftsmanship.com/posts/always-valid-domain-model/ Tue, 12 Jan 2021 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/always-valid-domain-model/ <div class="paragraph"> <p><strong>UPDATE 5/13/2021</strong>: the course has been published, check it now here: <a href="https://enterprisecraftsmanship.com/ps-ddd-validation">Validation and DDD</a>.</p> </div> <div class="paragraph"> <p>I&#8217;m working on a new Pluralsight course on the topic of validation and DDD, with the help of the FluentValidation library and .NET data annotations (attributes). So expect a couple of posts about validation in the near future.</p> </div> How to handle unique constraint violations https://enterprisecraftsmanship.com/posts/handling-unique-constraint-violations/ Tue, 08 Dec 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/handling-unique-constraint-violations/ <div class="paragraph"> <p>Today, we&#8217;ll discuss how to best handle unique constraint violations.</p> </div> C# 9 Records as DDD Value Objects https://enterprisecraftsmanship.com/posts/csharp-records-value-objects/ Tue, 24 Nov 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/csharp-records-value-objects/ <div class="paragraph"> <p>Today, we&#8217;ll talk about the new C# 9 feature, Records, and whether or not they can be used as DDD value objects.</p> </div> Domain model purity and lazy loading https://enterprisecraftsmanship.com/posts/domain-model-purity-lazy-loading/ Mon, 02 Nov 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/domain-model-purity-lazy-loading/ <div class="paragraph"> <p>I&#8217;m continuing the <a href="https://enterprisecraftsmanship.com/posts/domain-model-purity-completeness/">topic of domain model purity</a>. <a href="https://enterprisecraftsmanship.com/posts/domain-model-purity-current-time/">Last time</a>, we talked about domain model purity in the context of getting the current date and time. Today, we&#8217;ll discuss it with regards to lazy loading.</p> </div> Domain model purity and the current time https://enterprisecraftsmanship.com/posts/domain-model-purity-current-time/ Wed, 23 Sep 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/domain-model-purity-current-time/ <div class="paragraph"> <p>I&#8217;m continuing the <a href="https://enterprisecraftsmanship.com/posts/domain-model-purity-completeness/">topic of domain model purity</a>. This time, we&#8217;ll look at it with regards to getting the current date and time.</p> </div> <div class="paragraph"> <p>By the way, be sure to <a href="https://enterprisecraftsmanship.com/subscribe/">subscribe to my email list</a>. Not all discussions fit the format of a blog post (including some shorter takes on the topic of domain model purity vs completeness). I send those out as emails instead.</p> </div> Domain model purity vs. domain model completeness (DDD Trilemma) https://enterprisecraftsmanship.com/posts/domain-model-purity-completeness/ Tue, 04 Aug 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/domain-model-purity-completeness/ <div class="paragraph"> <p>I&#8217;ve been meaning to write this article for a long time and, finally, here it is: the topic of domain model purity versus domain model completeness.</p> </div> Is Equality Comparison a Code Pollution? https://enterprisecraftsmanship.com/posts/is-equality-comparison-code-pollution/ Mon, 13 Jul 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/is-equality-comparison-code-pollution/ <div class="paragraph"> <p>This post is about where to put the equality comparison logic: under the test or production code.</p> </div> How to Unit Test an Abstract Class https://enterprisecraftsmanship.com/posts/how-to-unit-test-an-abstract-class/ Wed, 24 Jun 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/how-to-unit-test-an-abstract-class/ <div class="paragraph"> <p>How to unit test an abstract class? Or a whole class hierarchy that depends on that abstract class? Let&#8217;s see.</p> </div> DRY vs DAMP in Unit Tests https://enterprisecraftsmanship.com/posts/dry-damp-unit-tests/ Mon, 08 Jun 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/dry-damp-unit-tests/ <div class="paragraph"> <p>In this post, we&#8217;ll make a deep dive into the DRY and DAMP principles and will talk about the false dichotomy around them.</p> </div> How to Strengthen Requirements for Pre-existing Data https://enterprisecraftsmanship.com/posts/strengthening-requirements-pre-existing-data/ Wed, 29 Apr 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/strengthening-requirements-pre-existing-data/ <div class="paragraph"> <p>Need to change validation rules but have pre-existing data that doesn&#8217;t follow the new rules? In this post, we&#8217;ll talk about how to do that properly.</p> </div> When to Mock https://enterprisecraftsmanship.com/posts/when-to-mock/ Wed, 15 Apr 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/when-to-mock/ <div class="paragraph"> <p>The use of mocks in unit testing is a controversial topic (maybe less so now than several years ago). I remember how, throughout my programming career, I went from mocking almost every dependency, to the "no-mocks" policy, and then to "only mock external dependencies".</p> </div> <div class="paragraph"> <p>None of this practices are good enough. In this article, I&#8217;ll show you which dependencies to mock, and which to use as is in your tests.</p> </div> Unit Testing Dependencies: The Complete Guide https://enterprisecraftsmanship.com/posts/unit-testing-dependencies/ Mon, 06 Apr 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/unit-testing-dependencies/ <div class="paragraph"> <p>In this article, we&#8217;ll review the types of unit testing dependencies. This is more of a reference article, to which I&#8217;ll be referring in future posts. Still, this topic is important for establishing the common vocabulary.</p> </div> EF Core and DDD: New online course https://enterprisecraftsmanship.com/posts/new-online-course-ddd-and-ef-core/ Thu, 05 Mar 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/new-online-course-ddd-and-ef-core/ <div class="paragraph"> <p>My new online training course DDD and EF Core: Preserving Encapsulation went live.</p> </div> 3 things that will make or break your project https://enterprisecraftsmanship.com/posts/3-things-that-will-make-or-break-your-project/ Tue, 04 Feb 2020 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/3-things-that-will-make-or-break-your-project/ <div class="paragraph"> <p>This article is about 3 things that can make or break any software project.</p> </div> Assertion messages in tests https://enterprisecraftsmanship.com/posts/assertion-messages-in-tests/ Mon, 16 Dec 2019 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/assertion-messages-in-tests/ <div class="paragraph"> <p>In this post, we&#8217;ll talk about whether or not you should use assertion messages in tests.</p> </div> Is Entity the same as Value Object? https://enterprisecraftsmanship.com/posts/is-entity-same-as-value-object/ Mon, 25 Nov 2019 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/is-entity-same-as-value-object/ <div class="paragraph"> <p>In this post, we&#8217;ll discuss an interesting question about whether the concepts of Entity and Value Object are the same.</p> </div> DDD and bulk operations https://enterprisecraftsmanship.com/posts/ddd-bulk-operations/ Mon, 28 Oct 2019 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/ddd-bulk-operations/ <div class="paragraph"> <p>Combining bulk operations with Domain-Driven Design is a tough problem. In this article, we&#8217;ll look at why that is so and discuss ways to marry the two.</p> </div> Combining ASP.NET Core validation attributes with Value Objects https://enterprisecraftsmanship.com/posts/combining-asp-net-core-attributes-with-value-objects/ Tue, 15 Oct 2019 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/combining-asp-net-core-attributes-with-value-objects/ <div class="paragraph"> <p>This is a continuation of the article series about some more advanced error handling techniques.</p> </div> Advanced error handling techniques https://enterprisecraftsmanship.com/posts/advanced-error-handling-techniques/ Mon, 23 Sep 2019 00:00:00 +0000 https://enterprisecraftsmanship.com/posts/advanced-error-handling-techniques/ <div class="paragraph"> <p>This post describes some (more) advanced error handling techniques. I&#8217;ll probably do a series because this topic is large and there&#8217;s quite a few things that need to be cleared out, but we&#8217;ll see.</p> </div> You are naming your tests wrong! https://enterprisecraftsmanship.com/posts/you-naming-tests-wrong/ Thu, 22 Aug 2019 12:55:20 +0000 https://enterprisecraftsmanship.com/posts/you-naming-tests-wrong/ <div class="paragraph"> <p>Giving your tests expressive names is important. Proper naming helps understand what the test verifies and how the underlying system behaves. In this post, we&#8217;ll take a look at a popular, yet inferior naming convention and see how it can be improved.</p> </div> I'm writing a book! https://enterprisecraftsmanship.com/posts/im-writing-book/ Tue, 16 Jul 2019 13:17:01 +0000 https://enterprisecraftsmanship.com/posts/im-writing-book/ <div class="paragraph"> <p>I&#8217;m writing a book called <strong>Unit Testing: Principles, Patterns and Practices</strong>.</p> </div> Merging domain events before dispatching https://enterprisecraftsmanship.com/posts/merging-domain-events-dispatching/ Thu, 06 Jun 2019 16:01:59 +0000 https://enterprisecraftsmanship.com/posts/merging-domain-events-dispatching/ <div class="paragraph"> <p>This post describes a common problem: how to deal with multiple domain events if raising of one of them must negate the others.</p> </div> CQRS and exception handling https://enterprisecraftsmanship.com/posts/cqrs-exception-handling/ Mon, 15 Apr 2019 21:55:27 +0000 https://enterprisecraftsmanship.com/posts/cqrs-exception-handling/ <div class="paragraph"> <p>In this article, I&#8217;d like to discuss one particular aspect of exception handling relevant to CQRS and the decorator pattern.</p> </div> When to validate commands in CQRS? https://enterprisecraftsmanship.com/posts/validate-commands-cqrs/ Wed, 20 Feb 2019 16:30:44 +0000 https://enterprisecraftsmanship.com/posts/validate-commands-cqrs/ <div class="paragraph"> <p>There&#8217;s a question that I didn&#8217;t cover in the course and that was raised at least twice since then: when to validate commands in CQRS?</p> </div> Are CQRS commands part of the domain model? https://enterprisecraftsmanship.com/posts/cqrs-commands-part-domain-model/ Thu, 31 Jan 2019 14:07:45 +0000 https://enterprisecraftsmanship.com/posts/cqrs-commands-part-domain-model/ <div class="paragraph"> <p>I published an online course about CQRS a couple months ago, and since then I realized that there are some topics I didn&#8217;t put enough emphasize on in that course, or didn&#8217;t cover at all. In the next several blog posts, I&#8217;m going to fill this gap.</p> </div> Hierarchy of value objects https://enterprisecraftsmanship.com/posts/hierarchy-value-objects/ Mon, 24 Dec 2018 17:23:01 +0000 https://enterprisecraftsmanship.com/posts/hierarchy-value-objects/ <div class="paragraph"> <p>This article is a response to a reader&#8217;s question. The question posed an interesting problem that I think will be interesting to a wider audience.</p> </div> CQRS vs Specification pattern https://enterprisecraftsmanship.com/posts/cqrs-vs-specification-pattern/ Tue, 06 Nov 2018 12:44:12 +0000 https://enterprisecraftsmanship.com/posts/cqrs-vs-specification-pattern/ <div class="paragraph"> <p>This is an article about how two DDD patterns contradict each other.</p> </div> New online course: CQRS in Practice https://enterprisecraftsmanship.com/posts/new-online-course-cqrs-in-practice/ Fri, 12 Oct 2018 12:02:58 +0000 https://enterprisecraftsmanship.com/posts/new-online-course-cqrs-in-practice/ <div class="paragraph"> <p>My new online training course CQRS in Practice went live.</p> </div> In Defense of Lazy Loading https://enterprisecraftsmanship.com/posts/defense-lazy-loading/ Mon, 10 Sep 2018 12:14:51 +0000 https://enterprisecraftsmanship.com/posts/defense-lazy-loading/ <div class="paragraph"> <p>In this article, we&#8217;ll talk about ORMs and lazy loading.</p> </div> Entity Identity vs Database Primary Key https://enterprisecraftsmanship.com/posts/entity-identity-vs-database-primary-key/ Mon, 23 Jul 2018 11:52:29 +0000 https://enterprisecraftsmanship.com/posts/entity-identity-vs-database-primary-key/ <div class="paragraph"> <p>Today, we&#8217;ll discuss the difference between identity in the DDD sense and database primary keys. We often mix the two together but are they really the same thing?</p> </div> EF Core 2.1 vs NHibernate 5.1: DDD perspective https://enterprisecraftsmanship.com/posts/ef-core-vs-nhibernate-ddd-perspective/ Wed, 13 Jun 2018 13:55:01 +0000 https://enterprisecraftsmanship.com/posts/ef-core-vs-nhibernate-ddd-perspective/ <p><strong>UPDATE 3/5/2020:</strong> I&rsquo;ve expanded on this article and updated its content for EF Core 3.1 in my new Pluralsight course <a href="https://enterprisecraftsmanship.com/ps-ef-core">DDD and EF Core: Preserving Encapsulation</a>.</p> <p>That was probably a long wait for those of you who follow my blog. But, better late than never, so here it is: another comparison of Entity Framework and NHibernate, in which I bash EF Core and present it as an unbiased review. Just kidding, I do try to be unbiased here to the best of my skills.</p> Value Objects and Identity https://enterprisecraftsmanship.com/posts/value-objects-identity/ Thu, 10 May 2018 11:52:00 +0000 https://enterprisecraftsmanship.com/posts/value-objects-identity/ <div class="paragraph"> <p>Today&#8217;s article is an answer to a reader&#8217;s question about the use of Value Objects to represent the identity of an entity.</p> </div> Non-determinism in tests https://enterprisecraftsmanship.com/posts/non-determinism-tests/ Mon, 16 Apr 2018 12:19:54 +0000 https://enterprisecraftsmanship.com/posts/non-determinism-tests/ <div class="paragraph"> <p>This is the final post in my series about unit testing anti-patterns. This one is about non-determinism in tests.</p> </div> Overriding methods in classes-dependencies https://enterprisecraftsmanship.com/posts/overriding-methods-classes-dependencies/ Mon, 09 Apr 2018 11:31:31 +0000 https://enterprisecraftsmanship.com/posts/overriding-methods-classes-dependencies/ <div class="paragraph"> <p>I&#8217;m continuing my unit testing anti-patterns article series. Today, we will talk about overriding methods in classes-dependencies.</p> </div> New course: Domain-Driven Design: Working with Legacy Projects https://enterprisecraftsmanship.com/posts/new-course-domain-driven-design-working-legacy-projects/ Wed, 28 Mar 2018 11:41:04 +0000 https://enterprisecraftsmanship.com/posts/new-course-domain-driven-design-working-legacy-projects/ <div class="paragraph"> <p>My new training course Domain-Driven Design: Working with Legacy Projects went live.</p> </div> NHibernate supports .NET Core 2.0 https://enterprisecraftsmanship.com/posts/nhibernate-now-supports-net-core-2-0/ Mon, 26 Mar 2018 11:31:31 +0000 https://enterprisecraftsmanship.com/posts/nhibernate-now-supports-net-core-2-0/ <div class="paragraph"> <p>Good news everyone! NHibernate 5.1 is released with the support of .NET Core 2.0 and .NET Standard 2.0.</p> </div> Code pollution https://enterprisecraftsmanship.com/posts/code-pollution/ Mon, 19 Mar 2018 14:51:32 +0000 https://enterprisecraftsmanship.com/posts/code-pollution/ <div class="paragraph"> <p>This is another post from my unit testing anti-patterns article series. Today, we will talk about code pollution.</p> </div> Value Objects and Error Messages https://enterprisecraftsmanship.com/posts/value-objects-error-messages/ Tue, 20 Feb 2018 12:34:00 +0000 https://enterprisecraftsmanship.com/posts/value-objects-error-messages/ <div class="paragraph"> <p>I haven&#8217;t done one of these for a while. This post is a review of a code submitted by a reader.</p> </div> Using Value Objects to represent technical concerns https://enterprisecraftsmanship.com/posts/using-value-objects-represent-technical-concerns/ Thu, 15 Feb 2018 13:03:48 +0000 https://enterprisecraftsmanship.com/posts/using-value-objects-represent-technical-concerns/ <div class="paragraph"> <p>I was asked a question recently which I find quite interesting. It is actually a part of a code review request (which I&#8217;ll cover next week) but I decided to elevate it to its own blog post.</p> </div> Leaking domain knowledge to tests https://enterprisecraftsmanship.com/posts/leaking-domain-knowledge-tests/ Tue, 30 Jan 2018 13:08:07 +0000 https://enterprisecraftsmanship.com/posts/leaking-domain-knowledge-tests/ <div class="paragraph"> <p>I&#8217;m continuing the series about unit testing anti-patterns I started a couple months ago. This article is about leaking domain knowledge to tests.</p> </div> To TDD or not to TDD https://enterprisecraftsmanship.com/posts/tdd-not-tdd/ Tue, 16 Jan 2018 12:10:50 +0000 https://enterprisecraftsmanship.com/posts/tdd-not-tdd/ <div class="paragraph"> <p>To TDD or not to TDD? Is this question even relevant or maybe it&#8217;s enough to just write tests, no matter before the code or afterward? Let&#8217;s see.</p> </div> NHibernate 5: async IO bound operations support https://enterprisecraftsmanship.com/posts/nhibernate-async-support/ Mon, 11 Dec 2017 13:00:45 +0000 https://enterprisecraftsmanship.com/posts/nhibernate-async-support/ <div class="paragraph"> <p>This news went mostly unnoticed but that&#8217;s actually a big one, at least for those of us who uses NHibernate as their primary ORM: NHibernate 5 now supports async IO bound operations.</p> </div> .NET Value Type (struct) as a DDD Value Object https://enterprisecraftsmanship.com/posts/net-value-type-ddd-value-object/ Mon, 04 Dec 2017 12:56:49 +0000 https://enterprisecraftsmanship.com/posts/net-value-type-ddd-value-object/ <div class="paragraph"> <p>I got a suggestion recently about using .NET structs to represent DDD Value Objects to which I repeated what I&#8217;ve been saying and writing for several years now: structs are not a good choice for DDD Value Objects. But then I realized that I never actually dove into the details of why it is so.</p> </div> <div class="paragraph"> <p>So here it is, the blog post where we&#8217;ll talk about using .NET Value Types (structs) as DDD Value Objects and what effect it has on the domain model, performance, and mapping the model to the database using ORMs.</p> </div> New course: Refactoring from Anemic Domain Model Towards a Rich One https://enterprisecraftsmanship.com/posts/refactoring-from-anemic-domain-model-towards-a-rich-one/ Tue, 14 Nov 2017 15:35:51 +0000 https://enterprisecraftsmanship.com/posts/refactoring-from-anemic-domain-model-towards-a-rich-one/ <div class="paragraph"> <p>My new training course Refactoring from Anemic Domain Model Towards a Rich One went live.</p> </div> Exposing private state to enable unit testing https://enterprisecraftsmanship.com/posts/exposing-private-state-to-enable-unit-testing/ Wed, 01 Nov 2017 13:49:49 +0000 https://enterprisecraftsmanship.com/posts/exposing-private-state-to-enable-unit-testing/ <div class="paragraph"> <p>Last time, we talked about making private methods public in order to enable unit testing. It&#8217;s not the only way people expose implementation details to the outside world for unit testing purposes, though. Today, we&#8217;ll look at a similar anti-pattern: exposing private state.</p> </div> Unit testing private methods https://enterprisecraftsmanship.com/posts/unit-testing-private-methods/ Mon, 23 Oct 2017 12:23:08 +0000 https://enterprisecraftsmanship.com/posts/unit-testing-private-methods/ <div class="paragraph"> <p><em>I&#8217;m starting a new series about unit testing anti-patterns. This post is the first article in that series</em>.</p> </div> <div class="paragraph"> <p>When it comes to unit testing, one of the most commonly asked questions is: how to test a private method?</p> </div> Domain events: simple and reliable solution https://enterprisecraftsmanship.com/posts/domain-events-simple-reliable-solution/ Tue, 03 Oct 2017 11:43:56 +0000 https://enterprisecraftsmanship.com/posts/domain-events-simple-reliable-solution/ <div class="paragraph"> <p>Today, I&#8217;d like to write about a simple and reliable way to implement domain events.</p> </div> Optimistic locking and automatic retry https://enterprisecraftsmanship.com/posts/optimistic-locking-automatic-retry/ Mon, 18 Sep 2017 12:11:18 +0000 https://enterprisecraftsmanship.com/posts/optimistic-locking-automatic-retry/ <div class="paragraph"> <p>In this post, I&#8217;m answering a reader&#8217;s question about how to combine an optimistic locking and automatic retry.</p> </div> <div class="paragraph"> </div> Value Object: a better implementation https://enterprisecraftsmanship.com/posts/value-object-better-implementation/ Mon, 28 Aug 2017 11:58:43 +0000 https://enterprisecraftsmanship.com/posts/value-object-better-implementation/ <div class="paragraph"> <p>This post is about a better implementation of Value Object.</p> </div> Short-term vs long-term perspective in software development https://enterprisecraftsmanship.com/posts/short-term-vs-long-term-perspective/ Thu, 17 Aug 2017 12:09:24 +0000 https://enterprisecraftsmanship.com/posts/short-term-vs-long-term-perspective/ <div class="paragraph"> <p>In this post, I&#8217;d like to talk about what I think is one of the most damaging attitudes a company or a person can have in the field of software development: short-sighted perspective.</p> </div> Always valid vs not always valid domain model https://enterprisecraftsmanship.com/posts/always-valid-vs-not-always-valid-domain-model/ Mon, 07 Aug 2017 11:58:22 +0000 https://enterprisecraftsmanship.com/posts/always-valid-vs-not-always-valid-domain-model/ <div class="paragraph"> <p>I&#8217;m back to the regular posting schedule. No more game development, at least for now.</p> </div> How I tried to get into game development and failed, part 3 https://enterprisecraftsmanship.com/posts/how-i-tried-to-get-into-game-development-and-failed-part-3/ Wed, 26 Jul 2017 13:24:25 +0000 https://enterprisecraftsmanship.com/posts/how-i-tried-to-get-into-game-development-and-failed-part-3/ Final part of my story about game development. First part, second part. Client side load balancing In the previous post, I wrote about performance optimizations. We figured that a single 1 CPU server in Azure could handle up to 600 simultaneous users spread across 3 game scenes (also known as game arenas; each scene takes one OS process). Now we needed a mechanism for distributing the players across multiple servers and game scenes in those servers. How I tried to get into game development and failed, Part 2 https://enterprisecraftsmanship.com/posts/how-i-tried-to-get-into-game-development-and-failed-part-2/ Mon, 24 Jul 2017 11:39:33 +0000 https://enterprisecraftsmanship.com/posts/how-i-tried-to-get-into-game-development-and-failed-part-2/ Part 2 of my story. You can read the first part here. Working on the tank design I wrapped up the previous post by saying that we decided to change the game idea from robots to tanks. We refined our vision of the game. There were going to be multiple tank levels to introduce a sense of progression. When starting up, you&#8217;d have a tank with the least amount of health (hit point, HP) and fire power, and proceed to a tank of the highest level. How I tried to get into game development and failed https://enterprisecraftsmanship.com/posts/how-i-tried-to-get-into-game-development-and-failed/ Mon, 17 Jul 2017 12:26:57 +0000 https://enterprisecraftsmanship.com/posts/how-i-tried-to-get-into-game-development-and-failed/ <div class="paragraph"> <p>If you read this blog regularly, you know that I usually write about DDD, functional programming, and enterprise software development best practices in general. These are the techniques I enjoy talking about, as well as applying them in my own projects. However, there was another field I always wanted to try myself in. That is game development. The ability to write my own games was the reason why I started learning to program in the first place. And I believe many programmers had this motivation behind their careers as well.</p> </div> <div class="paragraph"> <p>But let&#8217;s start from the beginning.</p> </div> How to request information from multiple microservices? https://enterprisecraftsmanship.com/posts/how-to-request-information-from-multiple-microservices/ Wed, 05 Jul 2017 11:59:01 +0000 https://enterprisecraftsmanship.com/posts/how-to-request-information-from-multiple-microservices/ <div class="paragraph"> <p>This post is about how to work with information that is spread across multiple microservices.</p> </div> Specification Pattern in C# Pluralsight course https://enterprisecraftsmanship.com/posts/specification-pattern-in-c-pluralsight-course/ Wed, 28 Jun 2017 11:03:22 +0000 https://enterprisecraftsmanship.com/posts/specification-pattern-in-c-pluralsight-course/ My new course Specification Pattern in C# for Pluralsight went live. Specification Pattern in C# This is a fairly short course (about an hour) which will teach you everything about the Specification Pattern and how to apply it in C# in combination with modern ORMs. From this course, you will learn: Use cases for the Specification Pattern. Common pitfalls people run into when implementing it. Value Objects: when to create one? https://enterprisecraftsmanship.com/posts/value-objects-when-to-create-one/ Thu, 15 Jun 2017 13:30:18 +0000 https://enterprisecraftsmanship.com/posts/value-objects-when-to-create-one/ <div class="paragraph"> <p>In this post, we&#8217;ll discuss Value Objects. Specifically, when to introduce them into your code.</p> </div> Ubiquitous Language and Naming https://enterprisecraftsmanship.com/posts/ubiquitous-language-naming/ Wed, 07 Jun 2017 10:31:54 +0000 https://enterprisecraftsmanship.com/posts/ubiquitous-language-naming/ <div class="paragraph"> <p>In this post, I&#8217;d like to talk about naming and Ubiquitous Language.</p> </div> Code review: Fabric class https://enterprisecraftsmanship.com/posts/code-review-fabric-class/ Thu, 01 Jun 2017 11:27:45 +0000 https://enterprisecraftsmanship.com/posts/code-review-fabric-class/ This is the second code review session where I showcase a real-world code example. If you want to learn more about this new format, check out this post. You can also request a review yourself. To do that, use the form on this page. Code review: Fabric class The full source code of this one is rather large for a single blog post, so I decided to pick the most interesting portions of it - those I think could be improved. IEnumerable vs IReadOnlyList https://enterprisecraftsmanship.com/posts/ienumerable-vs-ireadonlylist/ Wed, 24 May 2017 12:39:31 +0000 https://enterprisecraftsmanship.com/posts/ienumerable-vs-ireadonlylist/ <div class="paragraph"> <p><em>I apologize to everyone who&#8217;s waiting for my response to their code review requests. I was busy dealing with some personal stuff the last couple of weeks. Moving forward, I&#8217;m going to maintain a one post a week schedule where "regular" articles would take turns with code reviews. This article is a regular one, so the one next week would be a code review.</em></p> </div> <div class="paragraph"> <p>Today, I&#8217;d like to talk about IEnumerable and IReadOnlyList collection interfaces. We&#8217;ll discuss which of them is preferable and in what circumstance.</p> </div> The best way to implement a Main Something property https://enterprisecraftsmanship.com/posts/implementing-main-something-property/ Mon, 08 May 2017 11:51:22 +0000 https://enterprisecraftsmanship.com/posts/implementing-main-something-property/ <div class="paragraph"> <p>In this post, we will explore a common design problem: implementing a Main Something property. There&#8217;s an equally common solution to this problem which is sub-optimal in most cases.</p> </div> Code review: User Controller and error handling https://enterprisecraftsmanship.com/posts/code-review-user-controller-and-error-handling/ Mon, 01 May 2017 12:08:05 +0000 https://enterprisecraftsmanship.com/posts/code-review-user-controller-and-error-handling/ This is the first code review where I showcase some real-world code example and nitpick suggest improvements in it. If you want to learn more about this new format, check out this post. You can also request a review yourself. To do that, use the form on this page. Code review: User Controller and error handling The code in question is a UserController class with this Create method: publicIActionResult Create([FromBody] UserCreateModeluser) Call for code review https://enterprisecraftsmanship.com/posts/call-for-code-review/ Fri, 21 Apr 2017 11:06:44 +0000 https://enterprisecraftsmanship.com/posts/call-for-code-review/ <div class="paragraph"> <p>When I started this blog, I had one idea in mind: create some sort of repository of programming principles and practices so that I myself and other people would have an easier time navigating around them. That&#8217;s a nice goal to aim for but I noticed that when it comes to the actual process of writing code, having such a repository is often not enough.</p> </div> Temporal coupling and Immutability https://enterprisecraftsmanship.com/posts/temporal-coupling-and-immutability/ Mon, 10 Apr 2017 11:59:35 +0000 https://enterprisecraftsmanship.com/posts/temporal-coupling-and-immutability/ This topic is partly covered in my Applying Functional Principles in C# Pluralsight course, Module 2. Here, I&#8217;d like to elaborate on how temporal coupling and immutability are related to each other. Temporal coupling Temporal coupling is coupling that occurs when there are two or more members of a class that need to be invoked in a particular order. A common example is the following: var calculator = new PriceCalculator(); calculator. What is an exceptional situation in code? https://enterprisecraftsmanship.com/posts/what-is-exceptional-situation/ Thu, 30 Mar 2017 12:26:41 +0000 https://enterprisecraftsmanship.com/posts/what-is-exceptional-situation/ <div class="paragraph"> <p>This is a continuation of the topic of error handling. We&#8217;ll discuss what an exceptional situation in code actually is and see some examples of it.</p> </div> Error handling: Exception or Result? https://enterprisecraftsmanship.com/posts/error-handling-exception-or-result/ Mon, 13 Mar 2017 13:04:10 +0000 https://enterprisecraftsmanship.com/posts/error-handling-exception-or-result/ <div class="paragraph"> <p>In this post, we&#8217;ll look at some practical examples of error handling. We will see whether it is better to use exceptions or the Result class to deal with errors.</p> </div> Interfaces for repositories: do or don't? https://enterprisecraftsmanship.com/posts/interfaces-for-repositories/ Thu, 02 Mar 2017 14:11:08 +0000 https://enterprisecraftsmanship.com/posts/interfaces-for-repositories/ <div class="paragraph"> <p>Today&#8217;s topic is about interfaces for repositories. Should you introduce them? Or maybe it&#8217;s better to use repositories as is? Let&#8217;s see.</p> </div> On Automappers https://enterprisecraftsmanship.com/posts/on-automappers/ Thu, 16 Feb 2017 12:46:27 +0000 https://enterprisecraftsmanship.com/posts/on-automappers/ <div class="paragraph"> <p>This post is about some bad practices in using automappers.</p> </div> REST API response codes: 400 vs 500 https://enterprisecraftsmanship.com/posts/rest-api-response-codes-400-vs-500/ Tue, 31 Jan 2017 13:16:09 +0000 https://enterprisecraftsmanship.com/posts/rest-api-response-codes-400-vs-500/ <div class="paragraph"> <p>Today, I&#8217;d like to talk about the (sometimes subtle) difference between 4xx and 5xx response codes when programming a RESTful API. I&#8217;ll try to show when to return what code (400 or 500) and introduce a simple way to implement this logic on the server side.</p> </div> How long should a single method be? https://enterprisecraftsmanship.com/posts/how-long-should-a-single-method-be/ Thu, 19 Jan 2017 15:22:22 +0000 https://enterprisecraftsmanship.com/posts/how-long-should-a-single-method-be/ <div class="paragraph"> <p>This topic might seem trivial, especially if you look at all other articles that have beaten it to death already. But I would still like to make a couple of important points here. So, how long should a single method be?</p> </div> 2016 retrospective https://enterprisecraftsmanship.com/posts/2016-retrospective/ Fri, 23 Dec 2016 13:12:24 +0000 https://enterprisecraftsmanship.com/posts/2016-retrospective/ I already did this thing last year, so I thought I would do it again. Below is an overview of the articles I posted this year and a little bit of reflection on them. Retrospective It&#8217;s interesting to look at the progression of blogging topics throughout the whole year. They mostly followed the Pluralsight courses I was working on at the time. While writing a course, I remember finding lots of ideas that were worth extracting into a separate self-contained blog post. Custom exception types https://enterprisecraftsmanship.com/posts/custom-exception-types/ Thu, 08 Dec 2016 14:06:54 +0000 https://enterprisecraftsmanship.com/posts/custom-exception-types/ <div class="paragraph"> <p>Today&#8217;s topic is about custom exception types. That is whether or not you should write your own exception types to throw in different situations.</p> </div> OCP vs YAGNI https://enterprisecraftsmanship.com/posts/ocp-vs-yagni/ Mon, 28 Nov 2016 13:37:25 +0000 https://enterprisecraftsmanship.com/posts/ocp-vs-yagni/ In this post, I want to cover the topic of OCP vs YAGNI - contradictions between the Open/Closed Principle and the You aren’t gonna need it one. OCP Let&rsquo;s start with a refresher for what OCP is. The Open/Closed principle states that: Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification. It was first introduced by Bertrand Meyer in his canonical Object-Oriented Software Construction book. When to include external systems in testing scope https://enterprisecraftsmanship.com/posts/when-to-include-external-systems-into-testing-scope/ Tue, 15 Nov 2016 12:22:38 +0000 https://enterprisecraftsmanship.com/posts/when-to-include-external-systems-into-testing-scope/ Should you always mock out your database? Or should you include it in the unit/integration testing scope? What about other external systems? This post is based on my Pluralsight course about Pragmatic Unit Testing. Two types of external dependencies When it comes to external dependencies (dependencies outside the process that hosts your application, such as a database, a 3rd party system, etc.), there&#8217;s no single guideline regarding how to work with them in tests. OOP, FP, and object-relational impedance mismatch https://enterprisecraftsmanship.com/posts/oop-fp-and-object-relational-impedance-mismatch/ Thu, 03 Nov 2016 14:41:14 +0000 https://enterprisecraftsmanship.com/posts/oop-fp-and-object-relational-impedance-mismatch/ <div class="paragraph"> <p>Today&#8217;s topic is gonna be about OOP, FP, and object-relational impedance mismatch. The goal of this article is to show how object-oriented and functional paradigms deal with relational data stores.</p> </div> Verifying collaborations at the system edges https://enterprisecraftsmanship.com/posts/verifying-collaborations-at-system-edges/ Wed, 26 Oct 2016 13:00:53 +0000 https://enterprisecraftsmanship.com/posts/verifying-collaborations-at-system-edges/ Last week I wrote about when to use mocks. In this post, I&#8217;d like to outline a specific guideline which comes into play when you start working with mocks: verifying collaborations at the system edges. This article is based on my recent Pluralsight course about Pragmatic Unit Testing. Verifying collaborations at the system edges The use of mocks goes hand in hand with the style of unit testing which I call collaboration verification. Pragmatic Unit Testing Pluralsight course https://enterprisecraftsmanship.com/posts/pragmatic-unit-testing-pluralsight-course/ Mon, 10 Oct 2016 11:41:47 +0000 https://enterprisecraftsmanship.com/posts/pragmatic-unit-testing-pluralsight-course/ My new course Building a Pragmatic Unit Test Suite for Pluralsight went live. Building a Pragmatic Unit Test Suite Unit testing can be applied differently. Like many other things in programming, there are a lot of ways to mess up with it. It&#8217;s important to differentiate unit testing techniques that help bring confidence in your code base correctness from techniques that can potentially have a devastating effect on your entire test suite. How to know if your Domain model is properly isolated? https://enterprisecraftsmanship.com/posts/how-to-know-if-your-domain-model-is-properly-isolated/ Wed, 05 Oct 2016 11:42:50 +0000 https://enterprisecraftsmanship.com/posts/how-to-know-if-your-domain-model-is-properly-isolated/ <div class="paragraph"> <p>In this post, I&#8217;ll show a simple way to get to know if your domain model is properly isolated.</p> </div> Law of Demeter and immutability https://enterprisecraftsmanship.com/posts/law-of-demeter-and-immutability/ Thu, 29 Sep 2016 11:17:43 +0000 https://enterprisecraftsmanship.com/posts/law-of-demeter-and-immutability/ <div class="paragraph"> <p>In this post, we&#8217;ll discuss the Law of Demeter in the context of immutability.</p> </div> Email uniqueness as an aggregate invariant https://enterprisecraftsmanship.com/posts/email-uniqueness-as-aggregate-invariant/ Thu, 22 Sep 2016 12:32:57 +0000 https://enterprisecraftsmanship.com/posts/email-uniqueness-as-aggregate-invariant/ <div class="paragraph"> <p>Aggregates carry out many important functions. One of them is maintaining consistency boundaries. In this post, I write about the requirement of global email uniqueness and how it is related to aggregate invariants.</p> </div> Validation and DDD https://enterprisecraftsmanship.com/posts/validation-and-ddd/ Tue, 13 Sep 2016 12:40:39 +0000 https://enterprisecraftsmanship.com/posts/validation-and-ddd/ <div class="paragraph"> <p>Validation and DDD can be a tricky combination. How to perform validation in a way that doesn&#8217;t lead to domain knowledge leakage?</p> </div> Domain services vs Application services https://enterprisecraftsmanship.com/posts/domain-vs-application-services/ Thu, 08 Sep 2016 13:04:24 +0000 https://enterprisecraftsmanship.com/posts/domain-vs-application-services/ <div class="paragraph"> <p>In this post, we&#8217;ll take a look at domain services: what differs them from application services and when it is preferable to use one in addition to an application service.</p> </div> <div class="paragraph"> </div> Domain model isolation https://enterprisecraftsmanship.com/posts/domain-model-isolation/ Fri, 02 Sep 2016 00:59:13 +0000 https://enterprisecraftsmanship.com/posts/domain-model-isolation/ <div class="paragraph"> <p>I&#8217;ve been using the term "domain model isolation" for a long time already but just recently realized that its meaning might not be as obvious as I thought. In this post, I&#8217;ll try to describe what it means to properly isolate your domain model and why it is important.</p> </div> What is domain logic? https://enterprisecraftsmanship.com/posts/what-is-domain-logic/ Thu, 25 Aug 2016 11:13:31 +0000 https://enterprisecraftsmanship.com/posts/what-is-domain-logic/ <div class="paragraph"> <p>In this post, I&#8217;ll write about a couple of thoughts regarding what domain logic is and how to distinguish it from other types of logic.</p> </div> Nesting a Value Object inside an Entity https://enterprisecraftsmanship.com/posts/nesting-value-object-inside-entity/ Tue, 09 Aug 2016 11:24:39 +0000 https://enterprisecraftsmanship.com/posts/nesting-value-object-inside-entity/ <div class="paragraph"> <p>In this post, we are going to look at what to do if you are not able to treat some concept in your domain as a Value Object and have to make it an Entity. TL;DR: create a nested Value Object inside that Entity and relocate as much domain logic to that Value Object as possible.</p> </div> Representing a collection as a Value Object https://enterprisecraftsmanship.com/posts/representing-collection-as-value-object/ Thu, 04 Aug 2016 13:42:03 +0000 https://enterprisecraftsmanship.com/posts/representing-collection-as-value-object/ I was reviewing the list of topic ideas lately and found this question in the discussion to my DDD in Practice Pluralsight course. While I answered it - somewhat briefly - in the discussion thread, I think it&#8217;s worth a separate detailed blog post. The question itself goes like this: "Can you have a collection of Value Objects abstracted as a Value Object itself?" Or, in other words, can you represent a collection as a Value Object? What is an implementation detail? https://enterprisecraftsmanship.com/posts/what-is-implementation-detail/ Wed, 27 Jul 2016 10:39:00 +0000 https://enterprisecraftsmanship.com/posts/what-is-implementation-detail/ <div class="paragraph"> <p>I bet you encounter (and use) the term "implementation detail" a lot. But what it means, exactly? And how to see if something is an implementation detail?</p> </div> Unit testing anti-patterns: Structural Inspection https://enterprisecraftsmanship.com/posts/structural-inspection/ Thu, 21 Jul 2016 10:30:12 +0000 https://enterprisecraftsmanship.com/posts/structural-inspection/ <div class="paragraph"> <p>This post is about the practice of Structural Inspection in unit testing and why I personally consider it an anti-pattern.</p> </div> Growing Object-Oriented Software, Guided by Tests Without Mocks https://enterprisecraftsmanship.com/posts/growing-object-oriented-software-guided-by-tests-without-mocks/ Tue, 05 Jul 2016 11:06:27 +0000 https://enterprisecraftsmanship.com/posts/growing-object-oriented-software-guided-by-tests-without-mocks/ This is a review of the Growing Object-Oriented Software, Guided by Tests book (GOOS for short) in which I&#8217;ll show how to implement the sample project from the book in a way that doesn&#8217;t require mocks to be tested. Growing Object-Oriented Software, Guided by Tests Without Mocks Let me first explain why I&#8217;m doing a review of this book. If you read this blog regularly, you probably noticed that I&#8217;m pretty much against using mocks in tests. C# functional extensions NuGet library https://enterprisecraftsmanship.com/posts/c-functional-extensions-nuget-library/ Fri, 24 Jun 2016 09:18:40 +0000 https://enterprisecraftsmanship.com/posts/c-functional-extensions-nuget-library/ I&#8217;ve created a NuGet package out of the functional extensions I wrote about in this post series and in my Pluralsight course. C# functional extensions NuGet library Thanks to one of the listeners of my Functional C# course, I finally made a separate NuGet package which is based on the Result class I wrote about awhile ago. The package contains the following classes: Result ResultExtensions Pragmatic integration testing https://enterprisecraftsmanship.com/posts/pragmatic-integration-testing/ Tue, 21 Jun 2016 05:42:28 +0000 https://enterprisecraftsmanship.com/posts/pragmatic-integration-testing/ The topic described in this article is part of my Unit Testing Pluralsight course. When trying to break down unit testing, the bigger picture stays incomplete if you overlook the subject of integration testing. In this post, we&#8217;ll discuss how to make the most out of your integration tests with pragmatic integration testing. Integration tests are tests that, unlike unit tests, work with some of the volatile dependencies directly (usually with the database and the file system). Pragmatic unit testing https://enterprisecraftsmanship.com/posts/pragmatic-unit-testing/ Wed, 15 Jun 2016 06:24:12 +0000 https://enterprisecraftsmanship.com/posts/pragmatic-unit-testing/ The topic described in this article is part of my Unit Testing Pluralsight course. This post is about pragmatic unit testing: how to get the most out of your unit test suite. Pragmatic unit testing: black-box vs white-box Pragmatic unit testing is about investing only in the tests that yield the biggest return on your effort. In the previous posts, we discussed what traits a valuable test possess (high chance of catching a regression, low chance of producing a false positive, fast feedback) and how various styles of unit testing (functional, state verification, collaboration verification) differ in terms of their value proposition. Styles of unit testing https://enterprisecraftsmanship.com/posts/styles-of-unit-testing/ Thu, 09 Jun 2016 11:22:49 +0000 https://enterprisecraftsmanship.com/posts/styles-of-unit-testing/ The topic described in this article is part of my Unit Testing Pluralsight course. In this post, I&#8217;ll describe different styles of unit testing and compare them in terms of their value proposition. Styles of unit testing and their value proposition There are 3 major styles of unit testing. The first one is functional, where you feed an input to the system under test (SUT) and check what output it produces: Database Delivery Best Practices Pluralsight course https://enterprisecraftsmanship.com/posts/database-delivery-best-practices-pluralsight-course/ Wed, 08 Jun 2016 12:15:09 +0000 https://enterprisecraftsmanship.com/posts/database-delivery-best-practices-pluralsight-course/ My new course Database Delivery Best Practices for Pluralsight went live. Database Delivery Best Practices Database delivery is still something many programmers struggle with. It&#8217;s not always clear how to deal with the database schema differences in different environments, how to resolve merge conflicts that inevitably arise when more than one programmer works with the DB, how to make sure you don&#8217;t break the other teams' applications when you refactor the database structure and so on. Unit tests value proposition https://enterprisecraftsmanship.com/posts/unit-test-value-proposition/ Wed, 01 Jun 2016 11:29:53 +0000 https://enterprisecraftsmanship.com/posts/unit-test-value-proposition/ The topic described in this article is part of my Unit Testing Pluralsight course. I&#8217;m starting a new series which will be devoted to the topic of unit testing. In it, I&#8217;ll try to define what a valuable test is and show how the use of mocks fits into this picture. I&#8217;ll also describe the approach that I think has the best return of investments in terms of the value it provides. 7 notable NDC London 2016 talks https://enterprisecraftsmanship.com/posts/7-notable-ndc-london-2016-talks/ Sat, 21 May 2016 15:11:35 +0000 https://enterprisecraftsmanship.com/posts/7-notable-ndc-london-2016-talks/ <p>This post is a review of some talks from NDC London 2016 that I found interesting.</p> Immutable architecture https://enterprisecraftsmanship.com/posts/immutable-architecture/ Thu, 12 May 2016 11:25:46 +0000 https://enterprisecraftsmanship.com/posts/immutable-architecture/ The topic of immutable architecture described here is part of my Applying Functional Principles in C# Pluralsight course. In this post, I&#8217;d like to show a common approach to introducing immutability to your code base on an architectural level. Immutability, State, and Side Effects Before we start, let&#8217;s take a minute to define the terms. Most likely, you have already encountered them but I want to make sure we are on the same page here. Singleton vs Dependency Injection https://enterprisecraftsmanship.com/posts/singleton-vs-dependency-injection/ Wed, 04 May 2016 03:01:17 +0000 https://enterprisecraftsmanship.com/posts/singleton-vs-dependency-injection/ <div class="paragraph"> <p>This post is a showcase for the Singleton design pattern. In contrast to the common belief, Singleton is not inherently bad and I&#8217;ll try to show you in what circumstances it is a good choice.</p> </div> Defensive programming: the good, the bad and the ugly https://enterprisecraftsmanship.com/posts/defensive-programming/ Wed, 27 Apr 2016 11:48:48 +0000 https://enterprisecraftsmanship.com/posts/defensive-programming/ <div class="paragraph"> <p>In this post, I want to take a closer look at the practice of defensive programming.</p> </div> What is functional programming? https://enterprisecraftsmanship.com/posts/what-is-functional-programming/ Thu, 21 Apr 2016 13:49:23 +0000 https://enterprisecraftsmanship.com/posts/what-is-functional-programming/ The topic of functional programming described here is a part of my Applying Functional Principles in C# Pluralsight course. In this article, I&#8217;ll try to answer the question: what is functional programming? Functional programming So, what is functional programming? This term arises quite often and every author writing about it gives their own explanation. I&#8217;m no exception. In my opinion, the simplest and at the same time precise definition is the following: functional programming is programming with mathematical functions. Applying Functional Principles in C# Pluralsight course https://enterprisecraftsmanship.com/posts/applying-functional-principles-in-c-pluralsight-course/ Mon, 11 Apr 2016 11:11:46 +0000 https://enterprisecraftsmanship.com/posts/applying-functional-principles-in-c-pluralsight-course/ My new course Applying Functional Principles in C# for Pluralsight went live. Applying Functional Principles in C# What interesting about functional programming is that it allows you to adhere to the most important software development principles, just as the DDD practices do. It helps reduce the cognitive load when you deal with your code base and thus keep your software maintainable in a long term. This course is based on the article series I posted awhile back. Having the domain model separated from the persistence model https://enterprisecraftsmanship.com/posts/having-the-domain-model-separate-from-the-persistence-model/ Tue, 05 Apr 2016 12:52:02 +0000 https://enterprisecraftsmanship.com/posts/having-the-domain-model-separate-from-the-persistence-model/ <div class="paragraph"> <p>In this post, I&#8217;d like to write about a pretty common discussion in DDD circles: should one have the domain model separated from the persistence model? In other words, should you map your domain objects to the DB tables directly using an ORM or would it be better to use a separate set of Data Access Objects (DAOs) instead?</p> </div> Trying to impress people with your code https://enterprisecraftsmanship.com/posts/trying-to-impress-people-with-your-code/ Thu, 24 Mar 2016 11:29:24 +0000 https://enterprisecraftsmanship.com/posts/trying-to-impress-people-with-your-code/ <div class="paragraph"> <p>In this post, I&#8217;d like to write about the personal traits we all possess. Namely, I want to talk about being proud of your code and trying to impress people with it.</p> </div> Reference data as code https://enterprisecraftsmanship.com/posts/reference-data-as-code/ Thu, 17 Mar 2016 11:54:01 +0000 https://enterprisecraftsmanship.com/posts/reference-data-as-code/ <div class="paragraph"> <p>In this article, I&#8217;d like to write about a powerful technique that can potentially save you a lot of work and make your code much more concise: representing reference data as code.</p> </div> Link to an aggregate: reference or Id? https://enterprisecraftsmanship.com/posts/link-to-an-aggregate-reference-or-id/ Tue, 08 Mar 2016 12:14:14 +0000 https://enterprisecraftsmanship.com/posts/link-to-an-aggregate-reference-or-id/ <div class="paragraph"> <p>In this post, I write about 2 ways of representing a link to an aggregate.</p> </div> Mechanical approach to domain modeling https://enterprisecraftsmanship.com/posts/mechanical-approach-to-domain-modeling/ Mon, 29 Feb 2016 12:18:00 +0000 https://enterprisecraftsmanship.com/posts/mechanical-approach-to-domain-modeling/ <div class="paragraph"> <p>In this post, I&#8217;d like to talk about a mechanical approach to domain modeling. It sometimes arises when teams start applying Domain-Driven Design (DDD) principles to their projects and when they don&#8217;t have enough experience with it yet.</p> </div> Partially initialized entities anti-pattern https://enterprisecraftsmanship.com/posts/partially-initialized-entities-anti-pattern/ Mon, 22 Feb 2016 10:55:46 +0000 https://enterprisecraftsmanship.com/posts/partially-initialized-entities-anti-pattern/ The topic described in this article is a part of my Domain-Driven Design in Practice Pluralsight course. In this post, I&#8217;d like to talk about the partially initialized entities anti-pattern: anti-pattern that is often used in conjunction with repositories. Partially initialized entities Partially initialized entities are entities which are not fully constructed and returned as a result of some operation, usually an operation of fetching them from the database. 3 ways of achieving code correctness https://enterprisecraftsmanship.com/posts/3-ways-of-archiving-code-correctness/ Tue, 16 Feb 2016 13:00:36 +0000 https://enterprisecraftsmanship.com/posts/3-ways-of-archiving-code-correctness/ <div class="paragraph"> <p>Code correctness verification is not an easy task. At the same time, it&#8217;s one of the most important problems we have when we build software projects. In this article, I&#8217;ll compare 3 different ways of achieving code correctness.</p> </div> Specification pattern: C# implementation https://enterprisecraftsmanship.com/posts/specification-pattern-c-implementation/ Mon, 08 Feb 2016 13:30:46 +0000 https://enterprisecraftsmanship.com/posts/specification-pattern-c-implementation/ The topic described in this article is a part of my Specification Pattern in C# Pluralsight course. Specification pattern is not a new topic, there are many of its implementations on the Internet already. In this post, I&#8217;d like to discuss the use cases for the pattern and compare several common implementations to each other. 1. Specification pattern: what&#8217;s that? Specification pattern is a pattern that allows us to encapsulate some piece of domain knowledge into a single unit - specification - and reuse it in different parts of the code base. Classes internal to an aggregate: entities or value objects? https://enterprisecraftsmanship.com/posts/classes-internal-to-an-aggregate-entities-or-value-objects/ Mon, 01 Feb 2016 12:50:37 +0000 https://enterprisecraftsmanship.com/posts/classes-internal-to-an-aggregate-entities-or-value-objects/ <div class="paragraph"> <p>While such classes as Person and Money are pretty intuitive and can be easily attributed to either entities or value objects, the choice isn&#8217;t so obvious when it comes to classes that are internal to an aggregate. That is classes that aren&#8217;t roots of their own aggregates but rather parts of existing ones.</p> </div> Domain-Driven Design in Practice Pluralsight course https://enterprisecraftsmanship.com/posts/domain-driven-design-in-practice-pluralsight-course/ Fri, 22 Jan 2016 15:13:34 +0000 https://enterprisecraftsmanship.com/posts/domain-driven-design-in-practice-pluralsight-course/ My DDD in Practice course for Pluralsight went live. Why should you watch this course? I&#8217;ve been consistently applying DDD principles in my projects for about 6 years now and I can&#8217;t express enough how much value Domain-Driven Design has brought to me. The blue book written by Eric Evans was the most influential book I&#8217;ve ever read in my career. If you read this book too, you must have noticed that while it provides invaluable insights, it doesn&#8217;t tell much about how to implement them in practice. KISS vs database normalization https://enterprisecraftsmanship.com/posts/kiss-vs-database-normalization/ Mon, 18 Jan 2016 13:29:35 +0000 https://enterprisecraftsmanship.com/posts/kiss-vs-database-normalization/ In this article, I&#8217;d like to share an example of how the KISS principle can go against the database normalization principles and how to make a choice in such situation. The example Some time ago, I had a task which required me to implement linkage between the users of an application and their social accounts. At the time, we planned to add only two social providers - Facebook and Google - but others could be potentially integrated as well in the future. Entity vs Value Object: the ultimate list of differences https://enterprisecraftsmanship.com/posts/entity-vs-value-object-the-ultimate-list-of-differences/ Mon, 11 Jan 2016 13:01:15 +0000 https://enterprisecraftsmanship.com/posts/entity-vs-value-object-the-ultimate-list-of-differences/ The topic described in this article is a part of my Domain-Driven Design in Practice Pluralsight course. I wrote about entities and value objects some time ago. In this post, I&#8217;d like to talk about differences between Entity vs Value Object in more detail. I know, the topic isn&#8217;t new and there are a lot of articles on the Internet discussing it already. Nevertheless, I didn&#8217;t find any with an exhaustive, comprehensive description, so I decided to create my own. 2015 retrospective https://enterprisecraftsmanship.com/posts/2015-retrospective/ Tue, 22 Dec 2015 11:51:32 +0000 https://enterprisecraftsmanship.com/posts/2015-retrospective/ <div class="paragraph"> <p>It&#8217;s a small post with an overview of the articles I wrote during this year.</p> </div> Early exit is a tail call optimization of procedural languages https://enterprisecraftsmanship.com/posts/early-exit-is-tail-call-optimization/ Mon, 14 Dec 2015 12:46:32 +0000 https://enterprisecraftsmanship.com/posts/early-exit-is-tail-call-optimization/ <p>A couple of days ago, a nice analogy came to mind which I thought would be an interesting one to share: early exit is essentially a tail call optimization of procedural languages. Let&rsquo;s see how it is so.</p> C# regions is a design smell https://enterprisecraftsmanship.com/posts/c-regions-is-design-smell/ Tue, 08 Dec 2015 12:22:49 +0000 https://enterprisecraftsmanship.com/posts/c-regions-is-design-smell/ <div class="paragraph"> <p>Regions feature in C# is frowned upon by many. There are good reasons for that. In this post, I&#8217;d like to discuss why exactly you should avoid using them.</p> </div> Do you need an ORM? https://enterprisecraftsmanship.com/posts/do-you-need-an-orm/ Mon, 30 Nov 2015 13:06:08 +0000 https://enterprisecraftsmanship.com/posts/do-you-need-an-orm/ <div class="paragraph"> <p>Do you need an ORM for your project given you use a relational database? And not just some lightweight like Dapper but a big one: NHibernate, Entity Framework, Hibernate? I&#8217;d like to address this question with this post.</p> </div> Domain-centric vs data-centric approaches to software development https://enterprisecraftsmanship.com/posts/domain-centric-vs-data-centric-approaches/ Thu, 19 Nov 2015 13:08:25 +0000 https://enterprisecraftsmanship.com/posts/domain-centric-vs-data-centric-approaches/ In this post, I&#8217;d like to make a comparison of two approaches that prevail in the world of (mostly enterprise) software development: domain-centric and data-centric. If you read my last post (or any other post, quite frankly), you might have noticed I personally gravitate towards the domain-centric approach. Although this article is intended to be an impartial one, keep in mind that my bias can leak out. Domain-centric vs data-centric approaches The main difference between the two approaches is in the way people adhering to them treat software. Is SQL a good place for business logic? https://enterprisecraftsmanship.com/posts/is-sql-good-place-for-business-logic/ Wed, 11 Nov 2015 13:28:15 +0000 https://enterprisecraftsmanship.com/posts/is-sql-good-place-for-business-logic/ &lt;TL;DR&gt; No, it isn&#8217;t. While SQL is a Turing-complete language and we can use it to encode any business logic we want, placing business (domain) logic into SQL leads to a less maintainable solution comparing to one that uses an OO or functional language. Because of that, I advocate to limit the use of SQL to read-only queries (which can potentially contain business logic, that&#8217;s fine) and simple CRUD statements where possible. SQL vs NoSQL: you do want to have a relational storage by default https://enterprisecraftsmanship.com/posts/sql-vs-nosql-you-do-want-to-have-a-relational-storage-by-default/ Fri, 06 Nov 2015 12:39:28 +0000 https://enterprisecraftsmanship.com/posts/sql-vs-nosql-you-do-want-to-have-a-relational-storage-by-default/ <div class="paragraph"> <p>The concept of NoSQL databases has been around for a while, but there still are quite a few misunderstandings regarding the topic of relational SQL vs NoSQL databases. In this post, I&#8217;d like to clarify the most common misconceptions and discuss the primary use cases for each of them.</p> </div> Stages of competence: 2 ways of learning https://enterprisecraftsmanship.com/posts/stages-of-competence-2-ways-of-learning/ Mon, 19 Oct 2015 11:34:22 +0000 https://enterprisecraftsmanship.com/posts/stages-of-competence-2-ways-of-learning/ <div class="paragraph"> <p>When you enter some field as a novice, there is a lot of stuff you must learn in order to become proficient in it. The learning path can usually be broken down into 4 stages of competence which you can traverse in 2 different ways.</p> </div> Most valuable software development principles https://enterprisecraftsmanship.com/posts/most-valuable-software-development-principles/ Mon, 12 Oct 2015 11:28:37 +0000 https://enterprisecraftsmanship.com/posts/most-valuable-software-development-principles/ <div class="paragraph"> <p>I&#8217;d like to wrap up the "Most valuable software development principles" article series with this post.</p> </div> Making implicit assumptions explicit https://enterprisecraftsmanship.com/posts/making-implicit-assumptions-explicit/ Mon, 05 Oct 2015 11:34:07 +0000 https://enterprisecraftsmanship.com/posts/making-implicit-assumptions-explicit/ <div class="paragraph"> <p>Another software development principle I advocate you follow is making implicit assumptions explicit in your code. Let&#8217;s see what that means.</p> </div> C# and F# approaches to illegal state https://enterprisecraftsmanship.com/posts/c-and-f-approaches-to-illegal-state/ Mon, 28 Sep 2015 11:03:58 +0000 https://enterprisecraftsmanship.com/posts/c-and-f-approaches-to-illegal-state/ <p>You have probably heard of such phrase as &ldquo;make illegal states unrepresentable&rdquo; already. Basically, it stands for using some set of techniques for dealing with illegal states in your domain model. In this post, we&rsquo;ll look at how C# and F# allow us to handle them.</p> Coded UI vs White https://enterprisecraftsmanship.com/posts/coded-ui-vs-white/ Tue, 22 Sep 2015 11:14:21 +0000 https://enterprisecraftsmanship.com/posts/coded-ui-vs-white/ <div class="paragraph"> <p>Today, we&#8217;ll look at Coded UI and White automation frameworks in terms of building an automated UI test suite for a WPF application. We are going to compare them from different points of view, such as performance, the ease of getting started and maintainability. You will see which of these two frameworks suits what kind of projects and how to make a decision in your particular circumstances.</p> </div> Automating UI Tests for WPF Applications Pluralsight course https://enterprisecraftsmanship.com/posts/automating-ui-tests-wpf-applications-pluralsight-course/ Mon, 21 Sep 2015 11:21:51 +0000 https://enterprisecraftsmanship.com/posts/automating-ui-tests-wpf-applications-pluralsight-course/ My first course for Pluralsight went live! In it, I talk about techniques and best practices for building a UI test suite for WPF applications. During the course, I go through such topics as: Why we should invest our time into UI tests in the first place. Different types of manual tests and which of them we can automate. The comparison of Coded UI from Microsoft and open source White from TestStack. Fail Fast principle https://enterprisecraftsmanship.com/posts/fail-fast-principle/ Tue, 15 Sep 2015 11:26:42 +0000 https://enterprisecraftsmanship.com/posts/fail-fast-principle/ <div class="paragraph"> <p>The fail fast principle is underlying for many other software development practices. It comes out so often that it&#8217;s hard to cover all its appearances in a single article. Nevertheless, that is exactly what I&#8217;m going to do here :)</p> </div> DRY revisited https://enterprisecraftsmanship.com/posts/dry-revisited/ Fri, 11 Sep 2015 11:25:48 +0000 https://enterprisecraftsmanship.com/posts/dry-revisited/ <div class="paragraph"> <p>Another principle we should follow when building a software project is the DRY principle. The abbreviation stands for Don&#8217;t Repeat Yourself. While it seems pretty straightforward and intuitive, this principle is more than meets the eye. Let&#8217;s see how it is so.</p> </div> Cohesion and Coupling: the difference https://enterprisecraftsmanship.com/posts/cohesion-coupling-difference/ Wed, 02 Sep 2015 11:12:10 +0000 https://enterprisecraftsmanship.com/posts/cohesion-coupling-difference/ <div class="paragraph"> <p>This is another post on the most valuable principles in software development.</p> </div> <div class="paragraph"> <p>You might have heard of a guideline saying that we should aim to achieve low coupling and high cohesion when working on a code base. In this article, I&#8217;d like to discuss what this guideline actually means and take a look at some code samples illustrating it. I also want to draw a line between these two ideas and show the differences in them.</p> </div> Database versioning tools https://enterprisecraftsmanship.com/posts/database-versioning-tools/ Wed, 26 Aug 2015 11:14:04 +0000 https://enterprisecraftsmanship.com/posts/database-versioning-tools/ The topic described in this article is a part of my Database Delivery Best Practices Pluralsight course In the previous two articles, we looked at the theory behind the notion of database versioning. Today, I want to dive into practice and discuss the database versioning tools available at our disposal. Database versioning tools classes The tools on the market can be divided into two classes: those which follow the state-based approach and those that adhere to the migration-based principles. State vs migration-driven database delivery https://enterprisecraftsmanship.com/posts/state-vs-migration-driven-database-delivery/ Tue, 18 Aug 2015 11:14:21 +0000 https://enterprisecraftsmanship.com/posts/state-vs-migration-driven-database-delivery/ The topic described in this article is a part of my Database Delivery Best Practices Pluralsight course In the previous post, I wrote about the database versioning best practices. I&#8217;ve got a lot of feedback on that topic. One of the responses stated that the article was (admittedly) one-sided as it didn&#8217;t cover the other widely spread approach to managing the database delivery process. I decided to fill that gap and provide my own comparison of the two. Database versioning best practices https://enterprisecraftsmanship.com/posts/database-versioning-best-practices/ Mon, 10 Aug 2015 12:28:10 +0000 https://enterprisecraftsmanship.com/posts/database-versioning-best-practices/ The topic described in this article is a part of my Database Delivery Best Practices Pluralsight course. Keeping track of your application&#8217;s database is not an easy task. Database schemas tend to mismatch in different environments, data in one of the databases may miss some crucial piece of data. Such occasions can be irritating, especially when caught in production. The situation gets worse when you develop redistributable software. In this case, each of your clients has their own database instance whose structure may differ from others'. TDD best practices https://enterprisecraftsmanship.com/posts/tdd-best-practices/ Mon, 03 Aug 2015 11:43:57 +0000 https://enterprisecraftsmanship.com/posts/tdd-best-practices/ <div class="paragraph"> <p>Last week, we discussed the differences between stubs and mocks. Today, we&#8217;ll talk about some general tips and advice that regard to TDD and writing tests in general.</p> </div> <div class="ulist"> <ul> <li> <p><a href="https://enterprisecraftsmanship.com/2015/06/29/test-induced-design-damage-or-why-tdd-is-so-painful/">Test-induced design damage or why TDD is so painful</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/06/how-to-do-painless-tdd/">How to do painless TDD</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/13/integration-testing-or-how-to-sleep-well-at-nights/">Integration testing or how to sleep well at nights</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/20/the-most-important-tdd-rule/">The most important TDD rule</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/27/stubs-vs-mocks/">Stubs vs Mocks</a></p> </li> <li> <p><strong>TDD best practices</strong></p> </li> </ul> </div> Stubs vs Mocks https://enterprisecraftsmanship.com/posts/stubs-vs-mocks/ Mon, 27 Jul 2015 11:29:43 +0000 https://enterprisecraftsmanship.com/posts/stubs-vs-mocks/ <div class="paragraph"> <p>In this article, I&#8217;d like to discuss the differences in using stubs and mocks and show how you can abandon using mocks even in the cases where you need to verify that objects interact with each other correctly.</p> </div> <div class="ulist"> <ul> <li> <p><a href="https://enterprisecraftsmanship.com/2015/06/29/test-induced-design-damage-or-why-tdd-is-so-painful/">Test-induced design damage or why TDD is so painful</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/06/how-to-do-painless-tdd/">How to do painless TDD</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/13/integration-testing-or-how-to-sleep-well-at-nights/">Integration testing or how to sleep well at nights</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/20/the-most-important-tdd-rule/">The most important TDD rule</a></p> </li> <li> <p><strong>Stubs vs Mocks</strong></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/08/03/tdd-best-practices/">TDD best practices</a></p> </li> </ul> </div> The most important TDD rule https://enterprisecraftsmanship.com/posts/most-important-tdd-rule/ Mon, 20 Jul 2015 11:11:27 +0000 https://enterprisecraftsmanship.com/posts/most-important-tdd-rule/ <div class="paragraph"> <p>In the previous articles, we discussed what causes the pain while writing unit tests (mocks), and how to make TDD painless (get rid of the mocks). Today, I want to set the groundwork and discuss why mocks actually cause so much pain to us, developers.</p> </div> <div class="ulist"> <ul> <li> <p><a href="https://enterprisecraftsmanship.com/2015/06/29/test-induced-design-damage-or-why-tdd-is-so-painful/">Test-induced design damage or why TDD is so painful</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/06/how-to-do-painless-tdd/">How to do painless TDD</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/13/integration-testing-or-how-to-sleep-well-at-nights/">Integration testing or how to sleep well at nights</a></p> </li> <li> <p><strong>The most important TDD rule</strong></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/27/stubs-vs-mocks/">Stubs vs Mocks</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/08/03/tdd-best-practices/">TDD best practices</a></p> </li> </ul> </div> Integration testing or how to sleep well at nights https://enterprisecraftsmanship.com/posts/integration-testing-or-how-to-sleep-well-at-nights/ Mon, 13 Jul 2015 12:07:14 +0000 https://enterprisecraftsmanship.com/posts/integration-testing-or-how-to-sleep-well-at-nights/ <div class="paragraph"> <p>Unit testing is good at checking the correctness of your code in isolation, but it&#8217;s not a panacea. Only integration tests can give us confidence that the application we develop actually works as a whole. They are also a good substitute for mocks in the cases where you can&#8217;t test important business logic without involving external dependencies.</p> </div> <div class="ulist"> <ul> <li> <p><a href="https://enterprisecraftsmanship.com/2015/06/29/test-induced-design-damage-or-why-tdd-is-so-painful/">Test-induced design damage or why TDD is so painful</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/06/how-to-do-painless-tdd/">How to do painless TDD</a></p> </li> <li> <p><strong>Integration testing or how to sleep well at nights</strong></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/20/the-most-important-tdd-rule/">The most important TDD rule</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/27/stubs-vs-mocks/">Stubs vs Mocks</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/08/03/tdd-best-practices/">TDD best practices</a></p> </li> </ul> </div> How to do painless TDD https://enterprisecraftsmanship.com/posts/painless-tdd/ Mon, 06 Jul 2015 12:00:42 +0000 https://enterprisecraftsmanship.com/posts/painless-tdd/ <div class="paragraph"> <p>Last week, we nailed the root cause of the problems, related to so-called test-induced damage - damage we have to bring into our design in order to make the code testable. Today, we&#8217;ll look at how we can mitigate that damage, or, in other words, do painless TDD.</p> </div> <div class="ulist"> <ul> <li> <p><a href="https://enterprisecraftsmanship.com/2015/06/29/test-induced-design-damage-or-why-tdd-is-so-painful/">Test-induced design damage or why TDD is so painful</a></p> </li> <li> <p><strong>How to do painless TDD</strong></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/13/integration-testing-or-how-to-sleep-well-at-nights/">Integration testing or how to sleep well at nights</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/20/the-most-important-tdd-rule/">The most important TDD rule</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/27/stubs-vs-mocks/">Stubs vs Mocks</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/08/03/tdd-best-practices/">TDD best practices</a></p> </li> </ul> </div> Test-induced design damage or why TDD is so painful https://enterprisecraftsmanship.com/posts/test-induced-design-damage-or-why-tdd-is-so-painful/ Mon, 29 Jun 2015 11:13:09 +0000 https://enterprisecraftsmanship.com/posts/test-induced-design-damage-or-why-tdd-is-so-painful/ <div class="paragraph"> <p>I&#8217;m going to write a couple of posts on the topic of TDD. Over the years, I&#8217;ve come to some conclusions of how to apply TDD practices and write tests in general that I hope you will find helpful. I&#8217;ll try to distil my experience with it to several points which I&#8217;ll illustrate with examples.</p> </div> <div class="ulist"> <ul> <li> <p><strong>Test-induced design damage or why TDD is so painful</strong></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/06/how-to-do-painless-tdd/">How to do painless TDD</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/13/integration-testing-or-how-to-sleep-well-at-nights/">Integration testing or how to sleep well at nights</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/20/the-most-important-tdd-rule/">The most important TDD rule</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/07/27/stubs-vs-mocks/">Stubs vs Mocks</a></p> </li> <li> <p><a href="https://enterprisecraftsmanship.com/2015/08/03/tdd-best-practices/">TDD best practices</a></p> </li> </ul> </div> Encapsulation revisited https://enterprisecraftsmanship.com/posts/encapsulation-revisited/ Mon, 22 Jun 2015 11:57:52 +0000 https://enterprisecraftsmanship.com/posts/encapsulation-revisited/ <div class="paragraph"> <p>The third most important software development principle is Encapsulation.</p> </div> KISS revisited https://enterprisecraftsmanship.com/posts/kiss-revisited/ Mon, 15 Jun 2015 10:59:19 +0000 https://enterprisecraftsmanship.com/posts/kiss-revisited/ <div class="paragraph"> <p>Today, I&#8217;m going to discuss the KISS principle. I consider it the second most valuable software development principle.</p> </div> YAGNI revisited https://enterprisecraftsmanship.com/posts/yagni-revisited/ Thu, 11 Jun 2015 12:25:14 +0000 https://enterprisecraftsmanship.com/posts/yagni-revisited/ <div class="paragraph"> <p>I&#8217;m starting a new blog post series about the most valuable principles in software development. Not that I think you might not know them, but I rather want to share my personal experience and thoughts on that topic. The order in which I put those principles reflects their significance relative to each other, as it appears to be in my opinion.</p> </div> <div class="paragraph"> <p>That is quite a large subject and I&#8217;m going to dilute it with articles on other topics, so it might take a while.</p> </div> <div class="paragraph"> <p>Okay, let&#8217;s start.</p> </div> Make hard-coding your default choice https://enterprisecraftsmanship.com/posts/make-hard-coding-your-default-choice/ Mon, 08 Jun 2015 11:33:03 +0000 https://enterprisecraftsmanship.com/posts/make-hard-coding-your-default-choice/ Hard coding is often considered an anti-pattern. Having values that can change over time hard-coded in the source code requires recompilation every time these values actually change. While this statement is true, I think that hard coding should be the default choice when developing an application. Hard coding vs configuration file When you work on a project or feature, there always are some magic numbers or strings that potentially can change in future. Interfaces vs Interfaces https://enterprisecraftsmanship.com/posts/interfaces-vs-interfaces/ Tue, 02 Jun 2015 11:46:05 +0000 https://enterprisecraftsmanship.com/posts/interfaces-vs-interfaces/ <div class="paragraph"> <p>Today, I&#8217;d like to discuss the differences between interfaces, abstractions and .NET interfaces, as well as what the term "implementation details" means.</p> </div> Return the most specific type, accept the most generic type https://enterprisecraftsmanship.com/posts/return-the-most-specific-type/ Mon, 18 May 2015 11:22:56 +0000 https://enterprisecraftsmanship.com/posts/return-the-most-specific-type/ <div class="paragraph"> <p>I guess most developers heard the guideline stating that, when designing methods, you should return the most specific type and accept the most generic one. Is it always applicable? Let&#8217;s try to look at it from different perspectives.</p> </div> 3 misuses of ?. operator in C# 6 https://enterprisecraftsmanship.com/posts/3-misuses-of-operator-in-c-6/ Mon, 11 May 2015 11:14:28 +0000 https://enterprisecraftsmanship.com/posts/3-misuses-of-operator-in-c-6/ <p>I guess you already know about the safe navigation operator (<code>?.</code> operator) coming up in C# 6. While it&rsquo;s a nice syntactic sugar for quite a few cases, I&rsquo;d like to point out some misuses of it I&rsquo;m sure we will see when C# 6 is released.</p> Combining SQL Server and MongoDB using NHibernate https://enterprisecraftsmanship.com/posts/combining-sql-server-and-mongodb-using-nhibernate/ Wed, 06 May 2015 11:12:49 +0000 https://enterprisecraftsmanship.com/posts/combining-sql-server-and-mongodb-using-nhibernate/ <div class="paragraph"> <p>We often think that relational and NoSQL databases are somewhat incompatible. But what if we could use both within a single domain model? I&#8217;d like to show how to combine SQL Server and MongoDB together and discuss what benefits we could get from it.</p> </div> Validation logic and NHibernate event listeners https://enterprisecraftsmanship.com/posts/validation-logic-and-nhibernate-event-listeners/ Mon, 27 Apr 2015 11:41:12 +0000 https://enterprisecraftsmanship.com/posts/validation-logic-and-nhibernate-event-listeners/ <div class="paragraph"> <p>Today, I&#8217;d like to discuss a particular case with validating input data using NHibernate event listeners.</p> </div> Types of CQRS https://enterprisecraftsmanship.com/posts/types-of-cqrs/ Mon, 20 Apr 2015 11:23:40 +0000 https://enterprisecraftsmanship.com/posts/types-of-cqrs/ CQRS is a pretty defined concept. Often, people say that you either follow CQRS or not, meaning that it is some kind of a binary choice. In this article, I&#8217;d like to show that there is some wriggle room in this notion and how different types of CQRS can look like. Type 0: no CQRS With this type, you don&#8217;t have any CQRS whatsoever. That means you have a domain model and you use your domain classes for both serving commands and executing queries. DTO vs Value Object vs POCO https://enterprisecraftsmanship.com/posts/dto-vs-value-object-vs-poco/ Mon, 13 Apr 2015 12:07:17 +0000 https://enterprisecraftsmanship.com/posts/dto-vs-value-object-vs-poco/ <div class="paragraph"> <p>In this article, I&#8217;d like to clarify the differences in DTO vs Value Object vs POCO where DTO stands for Data Transfer Object, and POCO is Plain Old CLR Object, also known as POJO in Java environment.</p> </div> How we think https://enterprisecraftsmanship.com/posts/how-we-think/ Fri, 03 Apr 2015 11:56:51 +0000 https://enterprisecraftsmanship.com/posts/how-we-think/ <div class="paragraph"> <p>Did you think about how we think? How do we come up with a solution and how we decide whether it&#8217;s good or bad? It seems like a very interesting topic, so let&#8217;s dive in!</p> </div> 8 Resharper shortcuts everyone should know https://enterprisecraftsmanship.com/posts/8-resharper-shortcuts-everyone-should-know/ Fri, 27 Mar 2015 10:49:47 +0000 https://enterprisecraftsmanship.com/posts/8-resharper-shortcuts-everyone-should-know/ <div class="paragraph"> <p>If you use Resharper, you must have been using some (or maybe most) of its features already. But what I see a lot is that some really useful features are left unattended. I want to describe those lesser known yet very useful features that can help you in your day-to-day work.</p> </div> Functional C#: Handling failures, input errors https://enterprisecraftsmanship.com/posts/functional-c-handling-failures-input-errors/ Fri, 20 Mar 2015 11:37:11 +0000 https://enterprisecraftsmanship.com/posts/functional-c-handling-failures-input-errors/ The topic described in this article is a part of my Applying Functional Principles in C# Pluralsight course. In this article, I&#8217;m going to write about how to deal with failures and invalid input in a functional way. Functional C#: Immutability Functional C#: Primitive obsession Functional C#: Non-nullable reference types Functional C#: Handling failures and input errors Handling errors in C#: the common approach The concept of validation and error processing is well known, but the code required to handle it may become really annoying in languages like C#. Functional C#: Non-nullable reference types https://enterprisecraftsmanship.com/posts/functional-c-non-nullable-reference-types/ Fri, 13 Mar 2015 11:53:44 +0000 https://enterprisecraftsmanship.com/posts/functional-c-non-nullable-reference-types/ The topic described in this article is a part of my Applying Functional Principles in C# Pluralsight course. This is the third article in my Functional C# series. Functional C#: Immutability Functional C#: Primitive obsession Functional C#: Non-nullable reference types Functional C#: Handling failures and input errors C# non-nullable reference types: state of affairs Look at the code example below: Functional C#: Primitive obsession https://enterprisecraftsmanship.com/posts/functional-c-primitive-obsession/ Sat, 07 Mar 2015 13:42:23 +0000 https://enterprisecraftsmanship.com/posts/functional-c-primitive-obsession/ The topic described in this article is a part of my Applying Functional Principles in C# Pluralsight course. This is the second article in my Functional C# blog post series. Functional C#: Immutability Functional C#: Primitive obsession Functional C#: Non-nullable reference types Functional C#: Handling failures and input errors What is primitive obsession? Primitive obsession stands for using primitive types to model domain. Functional C#: Immutability https://enterprisecraftsmanship.com/posts/functional-c-immutability/ Mon, 02 Mar 2015 12:43:32 +0000 https://enterprisecraftsmanship.com/posts/functional-c-immutability/ The topic described in this article is a part of my Applying Functional Principles in C# Pluralsight course. I&#8217;m starting a series of articles in which I want to show how to program in C# in a more functional way. Functional C#: Immutability Functional C#: Primitive obsession Functional C#: Non-nullable reference types Functional C#: Handling failures and input errors Why immutability? Exceptions for flow control in C# https://enterprisecraftsmanship.com/posts/exceptions-for-flow-control/ Thu, 26 Feb 2015 20:18:56 +0000 https://enterprisecraftsmanship.com/posts/exceptions-for-flow-control/ The use of exceptions for flow control was raised quite a few times already (here&#8217;s a c2 discussion and here is a great question on SO). I&#8217;d like to summarize this topic and provide some common use cases along with code examples to handle them. Exceptions for flow control: why not? Generally, code is read more often than written. Most of the best practices aimed to simplify understanding and reasoning about the code: the simpler code, the fewer bugs it contains, and the easier it becomes to maintain the software. C# code contracts vs input validation https://enterprisecraftsmanship.com/posts/code-contracts-vs-input-validation/ Sat, 14 Feb 2015 15:43:42 +0000 https://enterprisecraftsmanship.com/posts/code-contracts-vs-input-validation/ <div class="paragraph"> <p>Input validation rules are often taken for code contracts. In this post, I&#8217;ll try to cover their differences and show what their common use cases are.</p> </div> Shared library vs Enterprise development https://enterprisecraftsmanship.com/posts/shared-library-vs-enterprise-development/ Sun, 08 Feb 2015 04:22:18 +0000 https://enterprisecraftsmanship.com/posts/shared-library-vs-enterprise-development/ <div class="paragraph"> <p>Most of the development principles are applicable to any software you might develop. Nevertheless, there are some differences between building a reusable library and an enterprise application. Those differences often become sticking points as we try to apply experience gained in one type of project to projects of the other type.</p> </div> <div class="paragraph"> <p>The differences between shared library and enterprise development grow from differences in requirements and lifetime support cycle.</p> </div> When inheritance is not an inheritance https://enterprisecraftsmanship.com/posts/when-inheritance-is-not-an-inheritance/ Mon, 02 Feb 2015 13:22:11 +0000 https://enterprisecraftsmanship.com/posts/when-inheritance-is-not-an-inheritance/ Nowadays, notion of composition over inheritance is quite widely accepted. It basically means that when designing a software, you should prefer composition to inheritance, although you could use either one. But what if several classes do have some common attributes? Do you need to extract a base class for them? When inheritance is not an inheritance In OOP, inheritance stands for "is-a" relation. That is, a class A can be treated as a sub-class of a class B if A *is* a B in a way that makes sense for our particular domain. IEnumerable interface in .NET and LSP https://enterprisecraftsmanship.com/posts/ienumerable-interface-in-net-and-lsp/ Fri, 30 Jan 2015 02:34:47 +0000 https://enterprisecraftsmanship.com/posts/ienumerable-interface-in-net-and-lsp/ I often see developers saying that in most cases, use of IEnumerable breaks LSP. Does it? Let&#8217;s find out. This is the continuation of my article Read-Only Collections and LSP. It this post, I&#8217;d like to discuss IEnumerable interface from a Liskov Substitution Principle (LSP) perspective. Liskov Substitution Principle and IEnumerable interface To answer the question whether or not use of IEnumerable breaks LSP, we should step back and see what it means to break LSP. How to increase your value as a developer https://enterprisecraftsmanship.com/posts/how-to-increase-your-value-as-developer/ Sat, 17 Jan 2015 23:53:08 +0000 https://enterprisecraftsmanship.com/posts/how-to-increase-your-value-as-developer/ <div class="paragraph"> <p>Did you think about what traits make developers great? Which one is the most valuable for the companies they are working for?</p> </div> <div class="paragraph"> <p>While there might be quite a few of them, I believe there&#8217;s one that employers value the most. I also believe getting that characteristic can drastically increase your value as a software developer.</p> </div> How to build Microservices wrong https://enterprisecraftsmanship.com/posts/how-to-build-microservices-wrong/ Sat, 10 Jan 2015 21:20:45 +0000 https://enterprisecraftsmanship.com/posts/how-to-build-microservices-wrong/ <div class="paragraph"> <p>Microservices have got a lot of traction last year. It&#8217;s always interesting to read about success stories other people have; they tend to inspire you to try this new trend out in your own project.</p> </div> <div class="paragraph"> <p>However, there are several traps you can fall into if you follow this trend without deep understanding of its fundamentals. Today, I&#8217;ll share some bad practices I saw one particular company used on its way to adopt microservices architecture.</p> </div> Value Objects explained https://enterprisecraftsmanship.com/posts/value-objects-explained/ Sat, 03 Jan 2015 12:18:27 +0000 https://enterprisecraftsmanship.com/posts/value-objects-explained/ I&#8217;ve already written about base entity class. Today, I&#8217;d like to continue with Value Object base class I use in my projects. Also, I&#8217;ll share some best practices regarding Value Objects implementation. Value Objects: what is it? An object that represents a descriptive aspect of the domain with no conceptual identity is called a Value Object. Value Objects are instantiated to represent elements of the design that we care about only for what they are, not who or which they are. Don't use Ids in your domain entities! https://enterprisecraftsmanship.com/posts/dont-use-ids-domain-entities/ Sat, 27 Dec 2014 23:36:27 +0000 https://enterprisecraftsmanship.com/posts/dont-use-ids-domain-entities/ How often do you see code like this in your domain model? public void Ship(int orderId, int customerId, string address) { Shipment shipment = _existingShipments.Single(x =&gt; x.OrderId == orderId); if (shipment.CustomerId == customerId) { // Do something  } } Seems pretty good, doesn&#8217;t it? Well, it doesn&#8217;t. I&#8217;ve already pointed using Ids in domain entities as a bad practice, but I see developers - even sophisticated ones - write such code over and over again, so this topic definitely deserves a separate article. Async/await in C#: pitfalls https://enterprisecraftsmanship.com/posts/pitfalls-of-async-await/ Sat, 20 Dec 2014 13:10:50 +0000 https://enterprisecraftsmanship.com/posts/pitfalls-of-async-await/ <div class="paragraph"> <p>I&#8217;d like to discuss some common pitfalls of async/await feature in C# and provide you with workarounds for them.</p> </div> I/O Threads Explained https://enterprisecraftsmanship.com/posts/io-threads-explained/ Sat, 13 Dec 2014 12:42:20 +0000 https://enterprisecraftsmanship.com/posts/io-threads-explained/ <div class="paragraph"> <p>Microsoft has released async/await feature in .Net 4.5. It&#8217;s a really great stuff as it significantly simplifies one of the most painful areas - asynchronous programming. Before that, Task Parallel Library (TPL) and Parallel LINQ (PLINQ) were released in .Net 4.0. They address problems with parallel programming - another painful area in .Net.</p> </div> <div class="paragraph"> <p>I often see programmers struggling with a question when to use each of these features. Let&#8217;s step back and recall what does it actually mean to be asynchronous or parallel.</p> </div> Separation of Concerns in ORM https://enterprisecraftsmanship.com/posts/separation-of-concerns-in-orm/ Sat, 06 Dec 2014 13:03:33 +0000 https://enterprisecraftsmanship.com/posts/separation-of-concerns-in-orm/ Last week we compared Entity Framework and NHibernate from a DDD perspective. Today, I&#8217;d like to dive deeper into what Separation of Concerns (SoC) is and why it is so important. We&#8217;ll look at some code examples and features that break the boundaries between the domain and persistence logic. Separation of concerns in ORM There are several concerns we deal with in software development. In most applications, there are at least three of them clearly defined: UI, business logic and database. C# Read-Only Collections and LSP https://enterprisecraftsmanship.com/posts/read-only-collections-and-lsp/ Sat, 22 Nov 2014 13:52:08 +0000 https://enterprisecraftsmanship.com/posts/read-only-collections-and-lsp/ I often see programmers saying that .NET read-only collections violate Liskov Substitution Principle. Do they? The quick answer is no but let&rsquo;s go through the whole story first. CQS with Database-Generated Ids https://enterprisecraftsmanship.com/posts/cqs-with-database-generated-ids/ Sat, 15 Nov 2014 13:31:14 +0000 https://enterprisecraftsmanship.com/posts/cqs-with-database-generated-ids/ Mark Seemann brings up a very interesting subject in his post: how to fit Command Query Separation principle in case you have to save a brand-new object in a database and also need the created id back? Sure, you can have GUIDs for identifiers (which have some drawbacks as I&rsquo;ll show later on), but what if you really need integers? I&rsquo;ve been asked the same question for several times, so in this post I&rsquo;ll share the solution I use for this problem. Entity Base Class https://enterprisecraftsmanship.com/posts/entity-base-class/ Sat, 08 Nov 2014 14:20:36 +0000 https://enterprisecraftsmanship.com/posts/entity-base-class/ <p>If you follow DDD principles, you eventually end up creating a base class for all the domain entities. It&rsquo;s a good idea as it allows you to gather common logic in one place. When you decide to do that, you inevitably face the question of what exactly should be included in that base entity and how it should be presented.</p> What is enterprise development? https://enterprisecraftsmanship.com/posts/what-is-enterprise-development/ Sat, 01 Nov 2014 19:58:54 +0000 https://enterprisecraftsmanship.com/posts/what-is-enterprise-development/ <div class="paragraph"> <p>It&#8217;s the first post on the blog I&#8217;m starting today. The idea to start blogging was with me quite for a while, so I decided to give it a try.</p> </div> https://enterprisecraftsmanship.com/book/1-star-review/ Mon, 01 Jan 0001 00:00:00 +0000 https://enterprisecraftsmanship.com/book/1-star-review/ Thank you! Thanks for your feedback. I'm grateful you took time to read the book. I'm always working to get better and I'll do my best to share useful ideas with you in the future. https://enterprisecraftsmanship.com/book/2-star-review/ Mon, 01 Jan 0001 00:00:00 +0000 https://enterprisecraftsmanship.com/book/2-star-review/ Thank you! Thanks for your feedback. I'm grateful you took time to read the book. I'm always working to get better and I'll do my best to share useful ideas with you in the future. https://enterprisecraftsmanship.com/book/3-star-review/ Mon, 01 Jan 0001 00:00:00 +0000 https://enterprisecraftsmanship.com/book/3-star-review/ Thank you! Thanks for your feedback. I'm grateful you took time to read the book. I'm always working to get better and I'll do my best to share useful ideas with you in the future. https://enterprisecraftsmanship.com/book/4-star-review/ Mon, 01 Jan 0001 00:00:00 +0000 https://enterprisecraftsmanship.com/book/4-star-review/ Thank you! Thanks for your feedback. I'm grateful you took time to read the book. I'm always working to get better and I'll do my best to share useful ideas with you in the future. https://enterprisecraftsmanship.com/book/5-star-review/ Mon, 01 Jan 0001 00:00:00 +0000 https://enterprisecraftsmanship.com/book/5-star-review/ Thank you! I'm so glad you enjoyed the book. If you have a minute, please consider leaving your 5-star review on Amazon or Goodreads. Write your Amazon review here. (If that link doesn't work for you, click here.) Write your Goodreads review here.