C# Value Objects to Solve Primitive Obsession

C# Value Objects to Solve Primitive Obsession

989 Lượt nghe
C# Value Objects to Solve Primitive Obsession
Value objects bundle related data together to represent real-world concepts. This makes your code more readable and easier to understand. By defining validation logic within value objects, you can prevent nonsensical data from entering your system in the first place. This helps to write more robust applications. Primitive obsession happens when you rely on basic data types like strings or numbers to represent complex ideas. Value objects act as a wrapper, giving them more structure and meaning. Primitive obsession is a code smell in C# that arises when developers rely too heavily on primitive data types to represent concepts in their program's domain. If you want to build better value objects In this tutorial, we'll learn what is primitive obsession, how to eliminate it, and how to create signature honest and DRY following Value Objects for your DDD(Domain driven design) projects in C#. Read my Blogs here: https://www.c-sharpcorner.com/members/tural-suleymani https://medium.com/@suleymanif.tural Timelines: 0:00 - What we're going to learn? 0:32 - Understanding real Domain Models 02:20 - Building Value objects 11:45 - what is a primitive obsession 13:03 - Eliminating DRY for Value Objects 19:50 - Method Signature Honesty for Value Objects 23:30 - implementing Web Api for Primitive Obsession 30:22 - Implementing AccountService 31:48 - Working around Account record 34:11 - Preparing missing API elements 37:00 - Applying final Value object implementation 39:20 - implicit explicit conversion 44:28 - Final notes