5 reasons NOT use ValueObject base class (with benchmarks)

Опубликовано: 18 Октябрь 2024
на канале: Daniel Tila - EnterpriseDotNet
304
5

Benchmarks: https://github.com/dtila/youtube/tree...
ValueObject implementation using struct:    • DDD: How to implement a ValueObject a...  

The video describes two approaches of implementing a ValueObject in DDD
1. Using the base class ValueObject
2. Using C# records

I give you 5 reasons to not use a base class when implementing a ValueObject object from Domain Driven Design.

00:00 Intro
01:29 Understand ValueObject base class
02:24 ValueObject usage example
02:40 First tradeoff - Design - coupling a technical with a business concern
03:07 Inheritance for ValueObject
03:41 Second issue - Performance - unable to allocate on stack
04:26 Third issue - Performance drawback by having an extra allocation
05:19 Fourth issue - Performance drawback by box value types
07:22 Fifth disadvantage - Design limitation and performance penalty
08:46 Benchmark
11:57 Which one should I choose


I build a real fully SaaS .NET platform using enterprise patterns like DDD.
The project is real and I will cover topics from simple development techniques to architecture, monitoring and monetization.

- - - - - - - - - - - - -
About me:
I'm Daniel, a dedicated freelancer who specializes in building software that lasts. I typically work with Microsoft's tools, like the .NET framework and Azure. I've got a knack for SQL Server, too, thanks to my certifications.
- - - - - - - - - - - - -
Connect with me:
https://danieltila.com
LinkedIn -   / ​